Visual Basic 6 – How to declare Public variable in a Project (Single Form)

Send Us a Sign! (Contact Us!)
--> (Word) --> (PDF) --> (Epub) --> (Text)
--> (XML) --> (OpenOffice) --> (XPS)

The keyword 'dim' declares variables and depending on where it is declared, its scope changes.

If you do:

Dim abcde as Integer 

inside a procedure, the variable's value can only be modified/accessed when inside that procedure. The same statement if made in the 'declarations' area (at the absolute top of the project) of the form code will make the variable accessible and modifiable by all procedures in that form, but not by the other forms.

[tweet]

The declaration of a public variable in a project you will have to write something like this:

Public {variable_name} as {variable_type}
Public intInteger1 as Integer
Public strStriung1 as String

SOURCE

LINK (allexperts.com)

LANGUAGE
ENGLISH