944,172 Members | Top Members by Rank

Ad:
Oct 29th, 2009
0

Displaying Input from one form onto another

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EntangledDesi is offline Offline
22 posts
since Oct 2009
Oct 29th, 2009
0
Re: Displaying Input from one form onto another
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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Oct 30th, 2009
0
Re: Displaying Input from one form onto another
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
Reputation Points: 20
Solved Threads: 18
Posting Whiz in Training
Vineeth K is offline Offline
206 posts
since Sep 2009
Oct 30th, 2009
0
Re: Displaying Input from one form onto another
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...
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Oct 31st, 2009
0
Re: Displaying Input from one form onto another
I agree with vb5prgrmr, Sample 1 (PASS) is the easiest and safest way of having the name available for ANY form...
Reputation Points: 329
Solved Threads: 347
Senior Poster
AndreRet is offline Offline
3,700 posts
since Jan 2008
Nov 3rd, 2009
0
Re: Displaying Input from one form onto another
Thank you for all the help..I was able to figure it out


vb5prgrmr: the third code was able to work. Thank you :]
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EntangledDesi is offline Offline
22 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Help Pls on how to disable popup menu on right click such as undo, cut, copy etc.
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: TempMsg ( Tempory Message )





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC