Results 1 to 15 of 15

Thread: [RESOLVED] [2005] Textbox help

  1. #1

    Thread Starter
    Addicted Member Phreak's Avatar
    Join Date
    Oct 2005
    Location
    Netherlands
    Posts
    132

    Resolved [RESOLVED] [2005] Textbox help

    Hello everyone,

    Ok so I am trying out this code; link but I stumbled upon an error..

    I want to put the text of "textbox1" (or the vdata string) into a textbox
    on another form (form2). Now, this is ezmode;

    Code:
    form2.textbox.text = textbox1.text
    Ofcourse this isnt working, can anyone tell me why ?
    Is it because it runs on another thread ?
    If i gave you good code/help, then dont forget to RATE
    Dont forget to mark your thread [Resolved] with the tools from the menu above...

  2. #2
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: [2005] Textbox help

    did you try

    form2.textbox.text = form1.textbox1.text
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  3. #3

    Thread Starter
    Addicted Member Phreak's Avatar
    Join Date
    Oct 2005
    Location
    Netherlands
    Posts
    132

    Re: [2005] Textbox help

    Quote Originally Posted by CoachBarker
    did you try

    form2.textbox.text = form1.textbox1.text

    I tried
    Code:
    form2.textbox.text = me.textbox1.text
    ,
    isnt working either
    If i gave you good code/help, then dont forget to RATE
    Dont forget to mark your thread [Resolved] with the tools from the menu above...

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Textbox help

    Form2 refers to the default instance of Form2. Unless that is the instance you are displaying to the user, you wont see anything happen.

    So you are obviously creating an instance of Form2 somewhere, that instance is unique in itself and if you wish to interact with that instance you'd do best to keep a reference to that form.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5
    Junior Member
    Join Date
    Jul 2008
    Posts
    28

    Re: [2005] Textbox help

    Cant your try putting it in a module, public varible?

    so you got a module with like?
    public textbox as string

    then public = form2.textbox.text

    then on form one have me.textbox.text = public?

    or something along them lines?

    Or am i just chatting bs?

    Sorry if it aint right im new and just an idea?

    Ben
    New To VB.Net
    Learning PHP and MYSQL aswell
    Currently In Development:
    Www.irn3rd.co.uk - Mysite
    Another Wesbite - In Planning
    WWW.jumpandslide.co.uk - Being redeveloped,

  6. #6
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: [2005] Textbox help

    As Atheist said you need an instance of Form 2 availble, it does not have to be visible though.

    vb Code:
    1. Form2.Show()
    2. Form2.Hide()

  7. #7

    Thread Starter
    Addicted Member Phreak's Avatar
    Join Date
    Oct 2005
    Location
    Netherlands
    Posts
    132

    Re: [2005] Textbox help

    Thanks for all the reply's !

    I have an instance of the form, its loaded, and visible right next form1..

    I am not receiving any error messages ;x..
    This code;
    Code:
    form2.textbox.text = form1.textbox1.text
    Does nothing for me.. Its very strange
    If i gave you good code/help, then dont forget to RATE
    Dont forget to mark your thread [Resolved] with the tools from the menu above...

  8. #8
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Textbox help

    Quote Originally Posted by Phreak
    Thanks for all the reply's !

    I have an instance of the form, its loaded, and visible right next form1..

    I am not receiving any error messages ;x..
    This code;
    Code:
    form2.textbox.text = form1.textbox1.text
    Does nothing for me.. Its very strange
    That is because you are accessing the wrong instance of Form2. You are, in this code, modifying the default instance of Form2, which is obviously not the same instance as you are displaying in the screen.
    Show us where you create and show Form2.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  9. #9
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: [2005] Textbox help

    did you copy this code straight from your project? If you have a spotted an error.

    Code:
    form2.textbox.text = form1.textbox1.text
    Take a look at it.

    Code:
    form2.textbox.text
    and
    Code:
    form1.textbox1.text
    do you mean textbox? or on form2 is it called textbox1?

    I originally thought that this was an error, because i though textbox is a preserved name, i think i may be wrong, but anyway you can check to make sure the names match.

  10. #10
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: [2005] Textbox help

    How are you showing Form2?

    There's a difference between the following two methods which I (and Atheist too by the looks of it) think is your problem.

    One method is showing the default instance of Form2, which you can then reference simply by "Form2. ...":
    Code:
    Form2.Show()
    The other method is creating a new instance of Form2 and showing that, which you can NOT reference by simply "Form2. ...":
    Code:
    Dim newForm As New Form2
    newForm.Show()
    In this second method, you should use "newForm.Textbox..." to reference it!

  11. #11
    Junior Member
    Join Date
    Sep 2008
    Posts
    25

    Re: [2005] Textbox help

    If you don't already have the answer....

    in form 2 onload use the following code
    vb Code:
    1. textbox1.text = form1.textbox1.text
    Nuksies

  12. #12
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: [2005] Textbox help

    OK then so what is the difference? They all accomplish the same thing.

    Code:
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.TextBox1.Text = "So what is the difference on how this works?"
        End Sub
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Form2.Show()
            ' passing the values to form two
            Form2.TextBox1.Text = Me.TextBox1.Text.Trim
            Form2.TextBox2.Text = Me.TextBox1.Text.Trim
            Me.Hide()
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim formTwo As New Form2
            formTwo.Show()
            ' passing the values to form two
            formTwo.TextBox1.Text = Me.TextBox1.Text.Trim
            formTwo.TextBox2.Text = Me.TextBox1.Text.Trim
            Me.Hide()
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Form3.Show()
            ' passing the value to Form3
            Form3.TextBox2.Text = Me.TextBox1.Text.Trim
            Me.Hide()
        End Sub
    
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Me.Close()
        End Sub
    End Class
    
    Option Explicit On
    
    Public Class Form2
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Form1.Show()
            Me.Close()
        End Sub
    End Class
    
    
    Option Explicit On
    
    Public Class Form3
        Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ' Getting the values from Form1
            Me.TextBox1.Text = Form1.TextBox1.Text.Trim
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Form1.Show()
            Me.Close()
        End Sub
    End Class
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  13. #13
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] Textbox help

    Quote Originally Posted by Phreak
    Hello everyone,

    Ok so I am trying out this code; link but I stumbled upon an error..

    I want to put the text of "textbox1" (or the vdata string) into a textbox
    on another form (form2). Now, this is ezmode;

    Code:
    form2.textbox.text = textbox1.text
    Ofcourse this isnt working, can anyone tell me why ?
    Is it because it runs on another thread ?
    Hi,

    You can try this:

    vb.net Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim Form2 As New Form2
    3.         Form2.Label1.Text = TextBox1.Text
    4.         Form2.Show()
    5.     End Sub

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  14. #14

    Thread Starter
    Addicted Member Phreak's Avatar
    Join Date
    Oct 2005
    Location
    Netherlands
    Posts
    132

    Re: [2005] Textbox help

    Thanks again for all the reply's everyone!..

    Ok I have tried everything, but its not putting any text in the
    textbox.

    I think its because part of the code is running on another thread.
    When I put a simple "form2.textbox.text = "hello"" into the form_load
    event. It works, but when I put that code into the "Private Sub UDPArrival"
    the code doesnt work...

    Anyone of you guys/girls has a Linksys router ?
    If i gave you good code/help, then dont forget to RATE
    Dont forget to mark your thread [Resolved] with the tools from the menu above...

  15. #15

    Thread Starter
    Addicted Member Phreak's Avatar
    Join Date
    Oct 2005
    Location
    Netherlands
    Posts
    132

    Re: [2005] Textbox help

    Ok.. I fixxed it, and my code is now working as it should be.

    I restarted my computer, did a rebuild of my code. And it was working!
    Did not changed any code, very strange...


    Thanks for all the help !
    If i gave you good code/help, then dont forget to RATE
    Dont forget to mark your thread [Resolved] with the tools from the menu above...

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