OT - Visual Basic 6

Currently reading:
OT - Visual Basic 6

K

Klemster

Guest
Does any one have any experience in coding VB6? I am having trouble declaring variables in multiple forms.

I have declared them as Global variables in a standard code module. I didn't declare them in the forms i am using them in and that doesn't work. i then declared them in both the standard code module and the forms and i still get an error! can anyone help??
 
Try declaring them as public, that worked for me on my coursework
 
Try adding a module and declare them there. I don't have vb6 installed at the moment but I just checked it in Access and it works on there. May be on the insert menu.

Stephen

boosignature.gif

Elusive Systems - http://www.elusivesystems.com
 
add a module to your project and declare your variable as public. or if you prefer not to add a module to the project then when you want to use your variable you have to type the namespace i.e if your vaiable is on form1 called "number" then to access it on form2 you'd have to type form1.number.

hope that helps

Gareth
 
i made a really stupid mistake declaring two global variables in the module and didn't spot it for ages. thanks anyway.

i was working away on it last night and my laptop crashed..spent hours trying the redo all the lost code in college this morning. the project was due for 3:30 and guess what happened at 2, VB encountered an error and closed the program..lost more or less everything i had done this morning. lesson learnt:SAVE, SAVE, SAVE every few mins!
 

Similar threads

M
Replies
12
Views
498
M
T
Replies
7
Views
572
Tommy K
T
J
Replies
1
Views
284
M
L
Replies
10
Views
583
Afonso
A
Back
Top