object reference

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Morris

    #1

    object reference

    In VB6 I use to call controls in another form by:



    With frmTaskList.lvw Task

    Select Case .Visible

    Case True

    .Items(1).SubIt ems.Add("dd")

    End Select

    End With



    VB.NET tells me "Reference to non-shared member requires an object
    reference".



    How do you do it in VB.NET?



  • Crirus

    #2
    Re: object reference

    In VB.NET a form is a type by itself
    You can try this

    Dim myfrmTaskList as frmTaskList
    When you create the frmTaskList set myfrmTaskList to that instance and then
    you can yse it as below

    with myFrmTaskList
    .....
    end with

    --
    Ceers,
    Crirus

    ------------------------------
    If work were a good thing, the boss would take it all from you

    ------------------------------

    "Simon Morris" <nzavalanche@ho tmail.com> wrote in message
    news:%23G1EGNbq DHA.4004@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > In VB6 I use to call controls in another form by:
    >
    >
    >
    > With frmTaskList.lvw Task
    >
    > Select Case .Visible
    >
    > Case True
    >
    > .Items(1).SubIt ems.Add("dd")
    >
    > End Select
    >
    > End With
    >
    >
    >
    > VB.NET tells me "Reference to non-shared member requires an object
    > reference".
    >
    >
    >
    > How do you do it in VB.NET?
    >
    >
    >[/color]


    Comment

    • Crirus

      #3
      Re: object reference

      Addintion: If you use that code in the form itself you can use Me keyword to
      call into form's instance

      --
      Ceers,
      Crirus

      ------------------------------
      If work were a good thing, the boss would take it all from you

      ------------------------------

      "Crirus" <Crirus@datagro up.ro> wrote in message
      news:OEvt$bbqDH A.1632@TK2MSFTN GP10.phx.gbl...[color=blue]
      > In VB.NET a form is a type by itself
      > You can try this
      >
      > Dim myfrmTaskList as frmTaskList
      > When you create the frmTaskList set myfrmTaskList to that instance and[/color]
      then[color=blue]
      > you can yse it as below
      >
      > with myFrmTaskList
      > ....
      > end with
      >
      > --
      > Ceers,
      > Crirus
      >
      > ------------------------------
      > If work were a good thing, the boss would take it all from you
      >
      > ------------------------------
      >
      > "Simon Morris" <nzavalanche@ho tmail.com> wrote in message
      > news:%23G1EGNbq DHA.4004@TK2MSF TNGP11.phx.gbl. ..[color=green]
      > > In VB6 I use to call controls in another form by:
      > >
      > >
      > >
      > > With frmTaskList.lvw Task
      > >
      > > Select Case .Visible
      > >
      > > Case True
      > >
      > > .Items(1).SubIt ems.Add("dd")
      > >
      > > End Select
      > >
      > > End With
      > >
      > >
      > >
      > > VB.NET tells me "Reference to non-shared member requires an object
      > > reference".
      > >
      > >
      > >
      > > How do you do it in VB.NET?
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Simon Morris

        #4
        Re: object reference

        I have try this but myFrmTaskList = Nothing.

        Simon

        "Crirus" <Crirus@datagro up.ro> wrote in message
        news:OEvt$bbqDH A.1632@TK2MSFTN GP10.phx.gbl...[color=blue]
        > In VB.NET a form is a type by itself
        > You can try this
        >
        > Dim myfrmTaskList as frmTaskList
        > When you create the frmTaskList set myfrmTaskList to that instance and[/color]
        then[color=blue]
        > you can yse it as below
        >
        > with myFrmTaskList
        > ....
        > end with
        >
        > --
        > Ceers,
        > Crirus
        >
        > ------------------------------
        > If work were a good thing, the boss would take it all from you
        >
        > ------------------------------
        >
        > "Simon Morris" <nzavalanche@ho tmail.com> wrote in message
        > news:%23G1EGNbq DHA.4004@TK2MSF TNGP11.phx.gbl. ..[color=green]
        > > In VB6 I use to call controls in another form by:
        > >
        > >
        > >
        > > With frmTaskList.lvw Task
        > >
        > > Select Case .Visible
        > >
        > > Case True
        > >
        > > .Items(1).SubIt ems.Add("dd")
        > >
        > > End Select
        > >
        > > End With
        > >
        > >
        > >
        > > VB.NET tells me "Reference to non-shared member requires an object
        > > reference".
        > >
        > >
        > >
        > > How do you do it in VB.NET?
        > >
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Crirus

          #5
          Re: object reference

          You must assign it to you form instance somewhere

          If you create the class after form you can use it's new to set the class
          myForm to the Form instance.

          Without a larger view of the code I cant tell you more

          --
          Ceers,
          Crirus

          ------------------------------
          If work were a good thing, the boss would take it all from you

          ------------------------------

          "Simon Morris" <nzavalanche@ho tmail.com> wrote in message
          news:%23DcOaWhq DHA.1096@TK2MSF TNGP11.phx.gbl. ..[color=blue]
          > I have try this but myFrmTaskList = Nothing.
          >
          > Simon
          >
          > "Crirus" <Crirus@datagro up.ro> wrote in message
          > news:OEvt$bbqDH A.1632@TK2MSFTN GP10.phx.gbl...[color=green]
          > > In VB.NET a form is a type by itself
          > > You can try this
          > >
          > > Dim myfrmTaskList as frmTaskList
          > > When you create the frmTaskList set myfrmTaskList to that instance and[/color]
          > then[color=green]
          > > you can yse it as below
          > >
          > > with myFrmTaskList
          > > ....
          > > end with
          > >
          > > --
          > > Ceers,
          > > Crirus
          > >
          > > ------------------------------
          > > If work were a good thing, the boss would take it all from you
          > >
          > > ------------------------------
          > >
          > > "Simon Morris" <nzavalanche@ho tmail.com> wrote in message
          > > news:%23G1EGNbq DHA.4004@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
          > > > In VB6 I use to call controls in another form by:
          > > >
          > > >
          > > >
          > > > With frmTaskList.lvw Task
          > > >
          > > > Select Case .Visible
          > > >
          > > > Case True
          > > >
          > > > .Items(1).SubIt ems.Add("dd")
          > > >
          > > > End Select
          > > >
          > > > End With
          > > >
          > > >
          > > >
          > > > VB.NET tells me "Reference to non-shared member requires an object
          > > > reference".
          > > >
          > > >
          > > >
          > > > How do you do it in VB.NET?
          > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...