C Colin Dec 3, 2003 #1 How do you pass variables in one form to another in VB.NET? I've looked through MSDN and three books but can't find how to.
How do you pass variables in one form to another in VB.NET? I've looked through MSDN and three books but can't find how to.
H Herfried K. Wagner [MVP] Dec 3, 2003 #2 * "Colin said: How do you pass variables in one form to another in VB.NET? I've looked through MSDN and three books but can't find how to. Click to expand... Add a public property to your 2nd form: \\\ Private m_UserName As String Public Property UserName() As String Get Return m_UserName End Get Set(ByVal Value As String) m_UserName = Value End Set End Property /// Then set this property: \\\ Dim f As New FooForm() f.UserName = "Foo Bar" f.Show() ///
* "Colin said: How do you pass variables in one form to another in VB.NET? I've looked through MSDN and three books but can't find how to. Click to expand... Add a public property to your 2nd form: \\\ Private m_UserName As String Public Property UserName() As String Get Return m_UserName End Get Set(ByVal Value As String) m_UserName = Value End Set End Property /// Then set this property: \\\ Dim f As New FooForm() f.UserName = "Foo Bar" f.Show() ///
C Colin Dec 3, 2003 #3 -----Original Message----- Add a public property to your 2nd form: \\\ Private m_UserName As String Public Property UserName() As String Get Return m_UserName End Get Set(ByVal Value As String) m_UserName = Value End Set End Property /// Then set this property: \\\ Dim f As New FooForm() f.UserName = "Foo Bar" f.Show() /// Click to expand... Thanks for your help. Colin
-----Original Message----- Add a public property to your 2nd form: \\\ Private m_UserName As String Public Property UserName() As String Get Return m_UserName End Get Set(ByVal Value As String) m_UserName = Value End Set End Property /// Then set this property: \\\ Dim f As New FooForm() f.UserName = "Foo Bar" f.Show() /// Click to expand... Thanks for your help. Colin
T Tore Gylver Dec 3, 2003 #4 You can also pass parameters in the forms constructor. If you search for "constructor" in help index or google you will find plenty of examples. Your calling code will be something like this in visual basic: Dim FRM as New TestForm (parameter1, parameter2, parameter3) Testform.show Parameter1,Parameter2 and Parameter3 can then be received in "testform" constructor: Public Sub New(Byval Parameter1 as int32, byval Parameter2 as string, Byval Parameter3 as string)) Regards Tore gylver thecurl online.no
You can also pass parameters in the forms constructor. If you search for "constructor" in help index or google you will find plenty of examples. Your calling code will be something like this in visual basic: Dim FRM as New TestForm (parameter1, parameter2, parameter3) Testform.show Parameter1,Parameter2 and Parameter3 can then be received in "testform" constructor: Public Sub New(Byval Parameter1 as int32, byval Parameter2 as string, Byval Parameter3 as string)) Regards Tore gylver thecurl online.no