Google
 

Sunday, December 10, 2006

Linking 2 forms in VB.Net and using textbox input from the first in the second

well it took me awhile to find out hw to do this properly but anyway its pretty simple to do this
Lets us take 2 forms Form1 & Form2 And we will call Form2 From Form1.. The coding for Form1 will involve declaring the textbox we will use as Shared Textbox..

Form1 Coding
Dim f2 As New Form2
Public Shared newname As TextBox

Private Sub cmdgoto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdgoto.Click
'makes txtuser textbox the public shared textbox newname
newname = txtuser

f2.Show()
Me.Hide()



End Sub


End Class


The line in red is the most important because it allows you 2 use the textbox commonly between the 2 forms

*after u add this to the first form u need not add any more coding 2 da second to initialise the above function mentioned in the heading .. ohh but wen u wnt 2 exit the program u must specify in the second form tht both form1 and form2 shuld be closed.


No comments: