Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code to be written in diff files

Status
Not open for further replies.

pujas

Programmer
Feb 2, 2005
22
0
0
US
I have wriiten a pgm in VB. Since i'am new to Vb i don't know you to put code in diff files and then access it from the main page.

What i have is a ctl file (an active-x obeject) whihc has all my code. It has global varaibles and functions which use those global varaibles.I also have a few global declaration.

where do i now store these global variables and declaration. Do i create a module file and store them there. If yes how would i access the global variables in the ctl file.
 
I tend to put all global variables in a module.. if they are declared public in a module, you can access them anywhere in the program just by using the Variable name. Placing these globals anywhere else requires you to call it like Control1.VariableName, rather than just VariableName


CTL_Code:
Public str3 as String

ModuleCode:
Public Const str as String = "Hello"
Public str2 as String

Form Code:
Private Sub Form_Load()
MsgBox str
str2 = "VB is FUN!"
MsgBox str2
Control1.str3 = "This is the bad way to do it"
msgbox Control1.str3
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top