object reference

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?
 
C

Crirus

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
 
C

Crirus

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

Menu Chen

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.
 
C

Crirus

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top