A global variable is visible in all methods of a given class.
To make global variables that can be accessed by all the classes of a project, declare them as public in one of your modules (for example, a module called "Global") and then refer to them as properties of that module (for example, Global.myvariable).
' Gambas class file X AS StringX is global
PUBLIC SUB _new() X = "tea with " END STATIC PUBLIC SUB Main() DIM hForm AS Fmain hForm = NEW Fmain hForm.show END PUBLIC SUB Button1_Click() DIM Y AS String Y = "milk"'Y is local
Label1.Text= X & Y END PUBLIC SUB Button2_Click() DIM Y AS String Y = "sugar" Label2.Text= X & Y END'you see the variables X and Y are different: