Passing variables between forms

  • Thread starter Thread starter Colin
  • Start date Start date
C

Colin

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.
 
* "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.

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()
///
 
-----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()
///

Thanks for your help.

Colin
 
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
 
Back
Top