Click to See Complete Forum and Search --> : Variable declaration


Prashant Joshi
February 28th, 1999, 01:21 AM
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.

Terry
February 28th, 1999, 11:54 AM
Prashant,


Try putting your public variables in a module file. Global/Public arrays

can also be put in a module file.


Good Luck,

Terry

Vinayak Sapre
February 28th, 1999, 11:52 PM
I don't think you can call without formname. I think it becomes kind of property of your form (class).

Chris Eastwood
March 1st, 1999, 05:47 AM
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