|
-
Oct 17th, 2008, 05:11 AM
#1
Thread Starter
Addicted Member
[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...
-
Oct 17th, 2008, 05:22 AM
#2
Frenzied Member
Re: [2005] Textbox help
did you try
form2.textbox.text = form1.textbox1.text
-
Oct 17th, 2008, 05:31 AM
#3
Thread Starter
Addicted Member
Re: [2005] Textbox help
 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...
-
Oct 17th, 2008, 05:42 AM
#4
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.
-
Oct 17th, 2008, 05:43 AM
#5
Junior Member
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
-
Oct 17th, 2008, 06:17 AM
#6
Frenzied Member
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:
Form2.Show()
Form2.Hide()
-
Oct 17th, 2008, 06:38 AM
#7
Thread Starter
Addicted Member
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...
-
Oct 17th, 2008, 06:40 AM
#8
Re: [2005] Textbox help
 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.
-
Oct 18th, 2008, 06:22 PM
#9
Frenzied Member
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.
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.
-
Oct 19th, 2008, 03:55 AM
#10
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. ...":
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!
-
Oct 19th, 2008, 05:32 AM
#11
Junior Member
Re: [2005] Textbox help
If you don't already have the answer....
in form 2 onload use the following code
vb Code:
textbox1.text = form1.textbox1.text
-
Oct 19th, 2008, 07:20 AM
#12
Frenzied Member
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
-
Oct 19th, 2008, 01:10 PM
#13
Re: [2005] Textbox help
 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:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Form2 As New Form2
Form2.Label1.Text = TextBox1.Text
Form2.Show()
End Sub
Wkr,
sparrow1
-
Oct 20th, 2008, 03:30 AM
#14
Thread Starter
Addicted Member
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...
-
Oct 20th, 2008, 06:27 AM
#15
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|