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 :
Form 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
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


Reply With Quote

