Here, we can define which includes members of the data and member functions. Then you create a class object and use the object to access the members of the class.Program :
Below is the source code to build a basic class and object. The program given is compiled and successfully executed.
'VB.Net program to create a simple class and object.
'VB.Net program to create a simple class and object. Class Sample Private num1 As Integer Private num2 As Integer Public Sub SetValues(ByVal n1 As Integer, ByVal n2 As Integer) num1 = n1 num2 = n2 End Sub Public Sub PrintValues() Console.WriteLine("Num1: " & num1) Console.WriteLine("Num2: " & num2) End Sub End Class Module Module1 Sub Main() Dim obj As New Sample() obj.SetValues(20, 30) obj.PrintValues() End Sub End Module
We created a Module1 module in the program above. We built a class sample here that includes two num1 and num2 data members. We have also created two SetValues() and PrintValues member functions here ().
To set the values for the data members, the SetValues() member function is used. The PrintValues() member function is used on the console screen to print the values of the data members.