Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

 

Dim a as string
a = "Text Example"

 

and then be able to go into form1 and have a textbox.text equal to "a".

Posted
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

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...