# Calling a variable in another form in vb6



## TheAtheist (May 20, 2006)

I'm building a small program for a few friends who use the Vatsim flight sim network. It requires a list of boolean variables. But what i want to be able to do, which is causing a problem, is to have all my boolean variables stored in the main, first loading form, and to call and change their state from the other forms. The form that holds the variables( declared in the general declarations section) is form2. The first variable is called stand1.



```
If (Form2.stand1 = False) Then
Form2.stand1 = True
Command1.BackColor = vbRed
Else
Form2.stand1 = False
Command1.BackColor = vbGreen
End If
```
Is that correct way to reference a variable in another form? If so, can anyone suggest what this will cause the following problem

"compile error: Method or Data member not found"

I know the variables are stored on the form i reference them to.

Any help, much appreciated

Cheers
Joe


----------



## prasams (Jul 31, 2009)

Have you declared the Stand1 variable as public?


----------



## TheAtheist (May 20, 2006)

I'm pretty sure i had done that by putting it in general declarations, but is this different if i want to call it in a different form?


----------



## enoctis (Aug 28, 2005)

In Form2's "General Declarations" use:


```
Public stand1 As Boolean
```
Now as long as Form2 is still loaded when the variable is called in any other form, then it can be used as Form2.stand1


----------



## TheAtheist (May 20, 2006)

Thanks Enoctis, such a simple thing i missed!


----------

