object reference

  • Thread starter Thread starter Simon Morris
  • Start date Start date
S

Simon Morris

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



With frmTaskList.lvwTask

Select Case .Visible

Case True

.Items(1).SubItems.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?
 
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
 
Addintion: If you use that code in the form itself you can use Me keyword to
call into form's instance
 
In dot net,form is an object.
For example ,you create form A and form B.
And now ,you want to call A's controls in B.
You can use :
Dim myForm as new frmTaskList
and then ,change your code to
**** With myForm.lvwTask****
I am sorry that I am not good at English.
 
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
 
Back
Top