|
-
Apr 30th, 2008, 11:50 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] VB6 Global variables
How can i set a value of a global variable declared on Form1 from Form2?
-
Apr 30th, 2008, 12:03 PM
#2
Re: VB6 Global variables
Code:
Form1.MyGlobalVarible = Whatever
-
Apr 30th, 2008, 12:21 PM
#3
Thread Starter
Fanatic Member
Re: VB6 Global variables
It doesn work 
How must the variable be declared?
I got an error saying Method or data member not found
-
Apr 30th, 2008, 12:33 PM
#4
Re: VB6 Global variables
You have to declare as a DIM
DIM myVariableName as String (shared with other forms tooo)
and use
Public myVariableName as String (needs to be in a MODULE)
Private myVariableName as String (shared with the current form only)
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Apr 30th, 2008, 12:47 PM
#5
Hyperactive Member
Re: VB6 Global variables
Declare the global variable in a module with this command at the top of your code below the "Option Explicit"
Global MyValue as Integer
-
Apr 30th, 2008, 01:22 PM
#6
Re: VB6 Global variables
You can declare a public variable in a form, and call it from another form.
Code:
'on form1
Option Explicit
Public strString As String
'on form2
Private Sub Form_Load()
Form1.strString = "Hack"
End Sub
-
Apr 30th, 2008, 01:38 PM
#7
Thread Starter
Fanatic Member
Re: VB6 Global variables
thanx guys, it works now
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|