VB.Net program to create an array of objects of the class
'VB.Net program to create an array of objects of the class.
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(2) As Sample
obj(0) = New Sample()
obj(1) = New Sample()
Console.WriteLine("Object(0) data:")
obj(0).SetValues(10, 20)
obj(0).PrintValues()
Console.WriteLine(vbCrLf & "Object(1) data:")
obj(1).SetValues(30, 40)
obj(1).PrintValues()
End Sub
End Module
Output
Object1 data:
Num1: 10
Num2: 20
Object2 data:
Num1: 30
Num2: 40
Press any key to continue . . .
Table of Contents