VB Variable Access
In VB6, how do you access a variable that''s on another form? Is this at all possible. I know you can access interface objects using !, but I can''t seem to get it to work for variables.
The variable must be assigned to public in the form in which it is used (and should also be declared in General Declerations (up the top)) to ensure that it can be seen from elsewhere in your program.
To assign a value to your variable:
To retrieve a value from your variable:
You can also access the properties and methods of the form itself in this way, as well as the properties and methods of any controls on the form. eg.
or
To assign a value to your variable:
formname.variablename = value
To retrieve a value from your variable:
another variable = formname.variablename
You can also access the properties and methods of the form itself in this way, as well as the properties and methods of any controls on the form. eg.
form1.txtname.text = "value"
or
form1.lstList.Clear
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement