Results 1 to 4 of 4

Thread: Get Value from a Class to a TextBox in a Form

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    165

    Get Value from a Class to a TextBox in a Form

    In this code I can Get SerialNumber and Name in MsgBox. I also would like to put them in three TextBox in a Form. How can I do this ?. Thank you.

    Class Code :

    Code:
    Public Class Item
    
        Public Shared Count As Integer = 1
        Private userNameValue As String
        Public Shared Sub ShareMethod()
            MsgBox("Current value of Count: " & Count)
            
        End Sub
    
        Public Sub New(ByVal Name As String)
            ' Use Count to initialize SerialNumber. 
            Me.SerialNumber = Count
            Me.Name = Name
            ' Increment the shared variable
            Count += 1
        End Sub
        Public SerialNumber As Integer
        Public Name As String
    
        Public Sub InstanceMethod()
            MsgBox("Information in the first object: " &
                Me.SerialNumber & vbTab & Me.Name)
            
        End Sub
    
    End Class
    Form Code :

    Code:
    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            TestShared()                
        End Sub
        
    Sub TestShared()
            ' Create two instances of the class. 
            Dim part1 As New Item("keyboard")
            Dim part2 As New Item("monitor")
    
            part1.InstanceMethod()
            part2.InstanceMethod()
            Item.ShareMethod()
        End Sub
    End Class
    Last edited by ebellounisoft; Aug 8th, 2017 at 08:03 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width