Results 1 to 9 of 9

Thread: Linking textboxes from different forms.... my codes not working?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Ma
    Posts
    19

    Linking textboxes from different forms.... my codes not working?

    Why isnt this code working right??

    On form 2:

    Private sub btnGO_click.....

    dim form1 as new form1

    form1.txtHello.text = "Hello"


    ****
    It doesnt update the display in the txthello textbox, but if I were do add form1.show() after it, it appears then? Im assuming its some sipmple extenstion to add to either form. or txthello. but I cant figure it out and ive worn my patience thin.

    Thanks guys.

    -Nick

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    First, why are you doing dim form1 as new form1 rather than using form1 directly? Do you need more than one instance of form1? Second, you may be confusing VB when you do dim form1 as new form1. Why not do something like dim frm as new form1 instead?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Ma
    Posts
    19
    Ok...

    then:


    Dim frmHello as new form1

    frmhello.textbox1.text = "Hello"


    it still doesnt work.....

    -Nick

  4. #4

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Ma
    Posts
    19
    It opens a 2nd instance of the form.....

    heres what Im trying to do-

    My program generates random backrounds, and shows the image number in a textbox on form1. I want the use to be able to click a button and have form2, credits, showup. From there, I want the user to be able to click on one of the people whos image I used and have that image number appear in the textbox on the first form...

    So I need to transfer the text from form2 to form1

    This is basicially what I want:

    VB Code:
    1. If Image = Nick then
    2. Generatebackround (nick)
    3. form1.txtImageNumber.text = "4"

    when I add form1.show after assinging the textbox "4" it opens another instance of form 1, with the text changed properly, but the first instance remains the same as before.


    -Nick

  6. #6
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    That's not how you do it. You do not need the dim blah as new form1. If Form1 is the name of the form, then just simply:

    Form1.textbox1.text = "Hello"

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Ma
    Posts
    19
    frm2GBackroundGenerator.txtImageNumber.Text = Credits.TextBox1.Text

    doesnt work- it tells me "Reference to a non-shared member requires an object reference"

    there is error lines under both frm2Gbackroundgenerator.txtImageNumber and frmCredits.Textbox1

    ?

    How can I "share" the item?

    -Nick

  8. #8
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    You are using .net. This forum is for vb6 and under. go here for your .net: http://www.vbforums.com/forumdisplay.php?s=&forumid=25

    5000 posts!

  9. #9

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Ma
    Posts
    19
    hmmmmm.....
    ok
    thanks.

    and let me be the first to congratulate you on the big 5000









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