-
Variable declaration
Hello,
It it true that variables declared in main form with Public statement
should be used with its form name in other succeeding forms or is there
any other way to call the Public variables just by name.
What about Global statement, Please help me.
Waiting for reply
Thanks in advance
Prashant.
-
Re: Variable declaration
Prashant,
Try putting your public variables in a module file. Global/Public arrays
can also be put in a module file.
Good Luck,
Terry
-
Re: Variable declaration
I don't think you can call without formname. I think it becomes kind of property of your form (class).
-
Re: Variable declaration
Hi
Since VB4, VB now treats all components as a Class - (except for Code modules).
You can create instances of Forms and access their properties just like a class module :
Dim mFrm As Form1
Set mFrm = New Form1
MsgBox mFrm.Width
or
With mFrm
MsgBox .Width
MsgBox .Height
End With
If you want to use a global variable - place it in a BAS module using 'Public' as the keyword. This can then be accessed from Forms/Classes/UserControls/Whatever in your project.
Regards
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb