Royson
Royson

Reputation: 2901

VB: Accessing variable throughout the application

I have no of forms in VB 6. I want to access the value of one variable throughout the application.
What is the way to create global variable in VB 6.

EDIT: I want to create only one global variable. I am new to VB,So Please give me some code snippet

Thanks.

Upvotes: 1

Views: 761

Answers (2)

appusajeev
appusajeev

Reputation: 2309

create a module and declare the variable there. Actually,you dont need to specify the Public keyword,things in module are by default treated as Public

Dim var1 as string

Upvotes: 0

AnthonyWJones
AnthonyWJones

Reputation: 189555

Create a module file (a file with the extension .bas) and in the (Declarations) section place something like the following in it:-

 Public MyVariable As String

Upvotes: 4

Related Questions