mushin
Programmer
- Oct 4, 2000
- 49
Hi
This is a prototype to return a lookup value to a calling form.
Enter some value on screen
Form1 calls form2
Data from form1 is modified
form2 exits
Form1 wants to display what was entered in form2.
Form1 Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tmpForm2 As New Form2
myText = tb.Text ' set var = screen var
tmpForm2.GetText(myText) ' call lookup form
tb.Text = myText ' set screen var to returned value
End Sub
Form2 code:
Public Class Form2
Inherits System.Windows.Forms.Form
Private mstrText1 As String
Public Function GetText(ByVal DefaultText As String) As String
tb2.Text = DefaultText ' set screen var to passed value
Me.ShowDialog()
Return mstrText1
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
mstrText1 = tb2.Text ' set value to be returned from value entered in screen var
Me.Hide()
End Sub
End Class
The data is passed ok to form2 and displays
I modify the data in form2 and exit
Form1 does NOT show the returned data...
I culled the gist of this from posts to this forum that seemed to satisfy the original poster, but this is nor working correctly.
Is the calling portion correct ?
It was not part of the post so maybe I screwed it up ?
* extraneous code ommitted (region, etc)
This is a prototype to return a lookup value to a calling form.
Enter some value on screen
Form1 calls form2
Data from form1 is modified
form2 exits
Form1 wants to display what was entered in form2.
Form1 Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tmpForm2 As New Form2
myText = tb.Text ' set var = screen var
tmpForm2.GetText(myText) ' call lookup form
tb.Text = myText ' set screen var to returned value
End Sub
Form2 code:
Public Class Form2
Inherits System.Windows.Forms.Form
Private mstrText1 As String
Public Function GetText(ByVal DefaultText As String) As String
tb2.Text = DefaultText ' set screen var to passed value
Me.ShowDialog()
Return mstrText1
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
mstrText1 = tb2.Text ' set value to be returned from value entered in screen var
Me.Hide()
End Sub
End Class
The data is passed ok to form2 and displays
I modify the data in form2 and exit
Form1 does NOT show the returned data...
I culled the gist of this from posts to this forum that seemed to satisfy the original poster, but this is nor working correctly.
Is the calling portion correct ?
It was not part of the post so maybe I screwed it up ?
* extraneous code ommitted (region, etc)