|
-
Jun 28th, 2000, 05:59 PM
#1
Thread Starter
Junior Member
Does anyone know what's going on???
Ok, this is going to be hard to explain. Well my problem revolves around public variables. I porperly declare all the variables as public in a module. When I assign to about 15 string variables in one form and then display these variables in another form, only about 4 variables are displayed. I've included some my code in this.
Thankyou
MODULE:
Public compnumber As String
Public y As String
Public firstname As String
Public lastname As String
Public house As String
Public tutor As String
Public housemaster As String
Public dob As String
Public pname As String
Public comments As String
Public winter As String
Public summer As String
Public add1 As String
Public add2 As String
Public picturefile As String
Public address As String
FORM 1:
Private Sub Form_Load()
compnumber = txtcnumber.Text
compnumber = compnumber & "*"
y = txtyear.Text
firstname = txtfirstn.Text
lastname = txtlastn.Text
housemaster = txthousemaster.Text
tutor = txttutor.Text
house = txthouse.Text
dob = txtdob.Text
pname = txtparent.Text
comments = txtcomment.Text
winter = txtwinter.Text
summer = txtsummer.Text
add1 = txtadditional1.Text
add2 = txtadditional2.Text
address = txtaddress.Text
End Sub
FORM 2:
Private Sub Form_Load()
txtcnumber.Text = Val(compnumber)
txtyear.Text = y
txtfirstn.Text = firstname
txtlastn.Text = lastname
txthousemaster.Text = housemaster
txttutor.Text = tutor
txthouse.Text = house
txtdob.Text = dob
txtparent.Text = pname
txtcomment.Text = comments
txtwinter.Text = winter
txtsummer.Text = summer
txtadditional1.Text = add1
txtadditional2.Text = add2
txtaddress.Text = address
End Sub
-
Jun 28th, 2000, 06:05 PM
#2
Fanatic Member
Not trying to be insulting, but is there data in these text boxes that you are assigning to the variables?
Iain, thats with an i by the way!
-
Jun 28th, 2000, 06:11 PM
#3
_______
looks a little confusing to me..
looks like you are using the same textboxes on both forms.
if you have identical textboxes on seperate forms this
could be a problem...
ie..
Form1
housemaster = txthousemaster.Text
tutor = txttutor.Text
house = txthouse.Text
etc.
Form2
txthousemaster.Text = housemaster
txttutor.Text = tutor
txthouse.Text = house
etc
try using form1
housemaster = form1.txthousemaster.txt
and in form2
form2.txthousemaster.text = housemaster
also note that you are loading the variables at form load
Do your textboxes have content at that time?
Use debug...put a stop on the final line of your sub
and then go back and passover your variables to see
if they are loaded.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 28th, 2000, 06:12 PM
#4
Lively Member
I think that the problem is with the declaration.
Try Global at place of Public.
Also, be careful to load the second form after the first is show and all the variables initialised. To make sure that all the variables initialised before, make a sub that initialised the variables before load the second form.
Code:
sub OpenSecondForm()
compnumber = txtcnumber.Text
compnumber = compnumber & "*"
y = txtyear.Text
firstname = txtfirstn.Text
lastname = txtlastn.Text
housemaster = txthousemaster.Text
tutor = txttutor.Text
house = txthouse.Text
dob = txtdob.Text
pname = txtparent.Text
comments = txtcomment.Text
winter = txtwinter.Text
summer = txtsummer.Text
add1 = txtadditional1.Text
add2 = txtadditional2.Text
address = txtaddress.Text
load form2
form2.show
end sub
-
Jun 29th, 2000, 01:23 PM
#5
Thread Starter
Junior Member
Actually I'm reading data from a txt file(I modified the code a bit), & yes all the variables have data in them, I even displayed them in the form to make sure!
-
Jun 29th, 2000, 01:56 PM
#6
Fanatic Member
What do you have problem with???
This code works perfectly for me (I even created 15 textboxes with those names to test it and it did work). Is there something else going on when you go from one form to another??
-
Jul 5th, 2000, 09:07 PM
#7
Thread Starter
Junior Member
Thanks
Thanks guys for helping me out, HeSaidJoe had the right idea for fixing this problem I had!!!!
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
|