Form Variables

Clay can U please tell me how do I refer to variables declared (Public if required) in one form from other form opened as vbmodal. Thanx in advance.

2 Replies

AM Anthony Mansfield July 3, 2002 02:18 PM UTC

Vipul - A commin way to access and share information between forms is the use of a property procedure. 1. In formA add a private form level variable 2. In formA add a property procedure that exposes the private variable 3. In formB access the property procedure. VB.NET Example: (FormA) Private m_intMyValue as integer Public Property MyProperty() As Integer Get Return m_intMyValue End Get Set(ByVal Value As Boolean) If m_intMyValue <> Value Then m_intMyValue = Value End If End Set End Property (FormB) dim intValue as integer = FormA.MyProperty I hope that helps. Anthony Mansfield Development Xfactor


VB Vipul Bhatt July 4, 2002 04:53 AM UTC

> Vipul - > > A commin way to access and share information between forms is the use of a property procedure. > > 1. In formA add a private form level variable > 2. In formA add a property procedure that exposes the private variable > 3. In formB access the property procedure. > > VB.NET Example: > > (FormA) > Private m_intMyValue as integer > > Public Property MyProperty() As Integer > Get > Return m_intMyValue > End Get > Set(ByVal Value As Boolean) > If m_intMyValue <> Value Then > m_intMyValue = Value > End If > End Set > End Property > > (FormB) > dim intValue as integer = FormA.MyProperty > > I hope that helps. > > Anthony Mansfield > Development Xfactor Hi Anthony. thanx. I just found a way to do this. FormA Friend Shared x as integer FormB msgbox(FormA.x) Anyway thanx a lot.

Loader.
Up arrow icon