|
-
May 8th, 2004, 08:52 PM
#1
Thread Starter
Junior Member
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
-
May 8th, 2004, 09:00 PM
#2
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?
-
May 8th, 2004, 09:16 PM
#3
Thread Starter
Junior Member
Ok...
then:
Dim frmHello as new form1
frmhello.textbox1.text = "Hello"
it still doesnt work.....
-Nick
-
May 8th, 2004, 09:20 PM
#4
VB Code:
Dim frmHello As New Form1
frmHello.Textbox1.Text = "Hello"
frmHello.Show
-
May 8th, 2004, 09:32 PM
#5
Thread Starter
Junior Member
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:
If Image = Nick then
Generatebackround (nick)
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
-
May 8th, 2004, 10:40 PM
#6
The picture isn't missing
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"
-
May 8th, 2004, 10:47 PM
#7
Thread Starter
Junior Member
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
-
May 8th, 2004, 11:11 PM
#8
The picture isn't missing
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!
-
May 8th, 2004, 11:13 PM
#9
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|