Displaying Input from one form onto another

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2009
Posts: 15
Reputation: EntangledDesi is an unknown quantity at this point 
Solved Threads: 0
EntangledDesi EntangledDesi is offline Offline
Newbie Poster

Displaying Input from one form onto another

 
0
  #1
Oct 29th, 2009
I have created form resembling a standard dialog box where some enters there name into a text box and then hits 'ok' taking them to the main form..On this form I need to get the name that is typed into the text box to be displayed on the main form.

How do I go about doing this?

The standard dialog box form is named frmInput and the text box is named txtName
The label where the Name is be displayed on the main form (frmSquare) is named Label1
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 910
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Posting Shark
 
0
  #2
Oct 29th, 2009
Several ways in which to do this and here are three...

1.) (Pass) Add a module and declare a public string variable and when user hits ok, you set the variable with the string you want. Then when the other form loads, that form retrieves the value and displays it in your label.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 'module code
  2. Option Explicit
  3.  
  4. Dim MyString As String
  5. '------------
  6. 'form that accepts input
  7. Option Explicit
  8.  
  9. Private Sub Command1_Click()
  10. MyString = Text1.Text
  11. Form2.Show
  12. Unload Me
  13. End Sub
  14. '--------------
  15. 'main form that displays input
  16. Option Explicit
  17.  
  18. Private Sub Form_Load()
  19. Label1.Caption = MyString
  20. End Sub

2.) (Push) From the form that recieves the input you can directly set the value of the label.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Option Explcit
  2.  
  3. Private Sub Command1_Click()
  4. Load Form2
  5. Form2.Label1.Caption = Text1.Text
  6. Form2.Show
  7. End Sub

3.) (Pull) When user clicks OK you hide the input form, show the display form and pull the information from the input form.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 'input form
  2. Option Explicit
  3.  
  4. Private Sub Command1_Click()
  5. Me.Hide
  6. Form2.Show
  7. Unload Me
  8. End Sub
  9. '-----------------
  10. 'Display Form
  11. Option Explicit
  12.  
  13. Private Sub Form_Load()
  14. Label1.Caption = Form1.Text1.Text
  15. End Sub




Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 178
Reputation: Vineeth K is an unknown quantity at this point 
Solved Threads: 9
Vineeth K's Avatar
Vineeth K Vineeth K is offline Offline
Junior Poster
 
0
  #3
Oct 30th, 2009
I think that code is too long to handle , may be this will help you !!
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Command1_Click()
  2. Me.Hide
  3. Form2.Show
  4. Form2.Label1.Caption = Text1.Text
  5. End Sub
Try it
Best Of Luck
Who wants to be a GOD ??
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 910
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Posting Shark
 
0
  #4
Oct 30th, 2009
Hey V, if you look closely you will see that is the same code that I labeled as 2.) (Push)... and if you read my post that is not just one example but three...
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 255
Reputation: AndreRet is an unknown quantity at this point 
Solved Threads: 38
AndreRet AndreRet is offline Offline
Posting Whiz in Training
 
0
  #5
Oct 31st, 2009
I agree with vb5prgrmr, Sample 1 (PASS) is the easiest and safest way of having the name available for ANY form...
Please mark questions as answered when done.

Be the ONE!!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 15
Reputation: EntangledDesi is an unknown quantity at this point 
Solved Threads: 0
EntangledDesi EntangledDesi is offline Offline
Newbie Poster
 
0
  #6
Nov 3rd, 2009
Thank you for all the help..I was able to figure it out


vb5prgrmr: the third code was able to work. Thank you :]
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 502 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC