| | |
How do I pass data in string from a form to another?
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2007
Posts: 5
Reputation:
Solved Threads: 0
There are many ways,
You could have a global variable in your second form to store which option was selected. Then just have a PUBLIC method in your second form called getSelected which returns your option
then as long as you open the second form modally, the first form will wait for the second form to close before executing the rest of the code.
or for VB2005
will open it in Modal
Hope this helps
You could have a global variable in your second form to store which option was selected. Then just have a PUBLIC method in your second form called getSelected which returns your option
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
<span class="ad_notxt"><code class="inlinecode">public function getSelected() return selection end function</code></span>
then as long as you open the second form modally, the first form will wait for the second form to close before executing the rest of the code.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
<span class="ad_notxt"><code class="inlinecode"> form2.show vbModal option = form2.getSelected() form2.dispose() </code></span>
or for VB2005
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
<span class="ad_notxt"><code class="inlinecode"> form2.showDialog() option = form2.getSelected() form2.dispose() </code></span>
will open it in Modal
Hope this helps
•
•
Join Date: Mar 2007
Posts: 59
Reputation:
Solved Threads: 5
Make a public form variable in the second form.
Load the second form modally.
Pass the value to the form as a propertie.
If you are ready in the form close is
The form properties stay preserved.
Do with them what you want (e.q. in the fist form).
Then, unload the second form.
'In Form1
Form2.Show vbModal
MsgBox "We still have the string: " & form2.my_second_string
Unload Form2
'Here Form2 is destroyed; with it the (public) string
'In Form2
Public My_Second_String as String
Private Sub Test()
My_Second_String = "The_Second_String"
Form2.hide
'Returns us to Form1, beyond: Form2.Show vbModal
'Preserve the string to take it to Form1
End Sub
--or--------------------------------------------------
'In Form1
Form2.Load
Form2.My_Second_String = "From Form1 to Form2"
Form2.Show
'in Form2
Public My_Second_String As String
Private Sub Test()
My_Second_String = "The_Second_String"
Form2.Hide
'returns us to Form1, beyond: Form2.Show vbModal
End Sub
(not tested!)
Load the second form modally.
Pass the value to the form as a propertie.
If you are ready in the form close is
The form properties stay preserved.
Do with them what you want (e.q. in the fist form).
Then, unload the second form.
'In Form1
Form2.Show vbModal
MsgBox "We still have the string: " & form2.my_second_string
Unload Form2
'Here Form2 is destroyed; with it the (public) string
'In Form2
Public My_Second_String as String
Private Sub Test()
My_Second_String = "The_Second_String"
Form2.hide
'Returns us to Form1, beyond: Form2.Show vbModal
'Preserve the string to take it to Form1
End Sub
--or--------------------------------------------------
'In Form1
Form2.Load
Form2.My_Second_String = "From Form1 to Form2"
Form2.Show
'in Form2
Public My_Second_String As String
Private Sub Test()
My_Second_String = "The_Second_String"
Form2.Hide
'returns us to Form1, beyond: Form2.Show vbModal
End Sub
(not tested!)
![]() |
Similar Threads
- Pass data to MessageBox (VB.NET)
- load data from access database into form (VB.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: where is wrong?
- Next Thread: Reading from non existant Text file
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





