Class to form Declaration

Talk2Tom11

Centurion
Joined
Feb 22, 2004
Messages
144
Location
Westchester, NY
I am working in VB.net and wondering if this is possible.

What I want to do is declare thinks within a class.

and then be able to call those items from any form within the project.


for example in class1.vb i want to put

Visual Basic:
Dim a as string
a = "Text Example"

and then be able to go into form1 and have a textbox.text equal to "a".
 
Visual Basic:
Public Class MyClass
    Dim a As String

    Sub New(InitialValue as String)
        a = InitialValue
    End Sub
    Public Property TextValue As String
        Get
            Return a
        End Get
        Set (value As String)
            a = value
        End Set
    End Property
End Class


'example usage
Sub Button1_Click(.....)
    Dim mClass As New MyClass("Some Value")

    TextBox1.Text = mClass.TextValue
End Sub
 
Back
Top