我有一个具有获取和设置属性的类
Public Property username() As String
Get
Return _username
End Get
Set(ByVal value As String)
_username = value
End Set
End Property
我想以一种形式设置值并以另一种形式获得相同的值我该怎么做?
我有一个具有获取和设置属性的类
Public Property username() As String
Get
Return _username
End Get
Set(ByVal value As String)
_username = value
End Set
End Property
我想以一种形式设置值并以另一种形式获得相同的值我该怎么做?
Simply declare that property on one form, so when you instantiate it you can set it before showing or while doing some other action:
Dim newForm As Form2 = new Form2()
newForm.UserName = "Alejandro"
newForm.Show()
This assumes that the property UserName
was declared on Form2
as public. It's perfectly possible to do the other way around, or even add that piece of data as a constructor parameter and keep the property private.