Click to See Complete Forum and Search --> : Global variables


Maarten Versteeg
January 10th, 2000, 09:37 AM
Hi,

Does anyone know how to declare global variables, which are available in the whole project(all the forms).
Please send some code example, if possible.

Thanx,
Maarten

Chris Eastwood
January 10th, 2000, 09:47 AM
Add a BAS module to your project (called modGlobals.BAS for example), then you can add global variables there, eg :


public g_SomeGlobalString as string
public Const SOME_CONSTANT as string = "Some string That Doesnt Change"
public Const SECONDS_IN_AN_HOUR as Long = 60 * 60




In Form1 - form_load procedure :


MsgBox SOME_CONSTANT
g_SomeGlobalString = "Something else"
MsgBox g_SomeGlobalString





Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Maarten Versteeg
January 11th, 2000, 05:56 AM
This one works also like I wanted.

Thanx!