Results 1 to 7 of 7

Thread: Does anyone know what's going on???

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    23

    Angry 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

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    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!

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    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

  4. #4
    Lively Member
    Join Date
    Jun 2000
    Location
    Belgium
    Posts
    77

    Smile

    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

    KWell

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    23

    Angry

    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!

  6. #6
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    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??

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    23

    Talking 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
  •  



Click Here to Expand Forum to Full Width