Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a string 2

Status
Not open for further replies.

sand133

Programmer
Jun 26, 2004
103
GB
hi guys (once again),


i have a form(form1) this has a textfield and a button. when the enters their name and presses the button i want the name to appear on form2.




any ideas?

thanks
 
There are many ways of doing something like that, and to be honest i am not sure what the 'correct' way is, so i will give you a few ideas below and you can choose the one which best suits your needs

1 - Set the label on the form2
Dim objNewForm as new Form2
objNewForm.label1.text = strPersonName
objNewForm.show

2 - Set a property on the new form so you can use it
Dim objNewFOrm as new Form2
objNewForm.PersonName = strPersonName
objNewForm.show

and remember to create a public property on the form

3 - Set the parent of Form2 to Form1
Dim objNewForm as new Form2
objNewFOrm.parent = me
objNewForm.show

Then on the form you can
Dim objParent as Form1 = me.parent
label1.text = me.parent.textbox1.text


There are other ways, if none of theese meet your needs let me know and i will throw a few more your way :)

 
thanks mate, but can you throw some more ideas. i will give u the low down on what im trying to do , when a user logs in successfully into the application i want their username by which they loged in with to appear on the main form.

thanks
 
Define a PUBLIC string (e.g USER) in the module

Then when the user logs in save their ID in the USER string. (by the way it should be possible to determine the USERID that they signed ontot he machine with from the system if you prefer that method).

Then in the Form1_Load event set the Text of where you want the USERID to be USER.

ie Label1.text = USER

Hope this helps
 
thanks kevin, i actually wrote some code similar to what u mentioned above, but i was going wrong somewhere, after reading your thread I relised i had to declare the string public, silly of me.

anyway thanks guys
 
What about if you have four forms and you want the name from form1 to be passed onto form4 but you show form2 then form3 then form4

Thankx,

Donnie
 
the actual order of the showing isnt important.
once you intialised the form with the new keyword you can pass information to it.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
What a wonderfull world - Louis armstrong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top