You just put parameters into the New method and then set those parameters equal to the values.
So, say your student has properties called FirstName, LastName and Grade and you want to populate those when you create the object.
The syntax would be like:
vb Code:
Public Class Student private _firstName as String private _lastName as String private _grade as Integer Public Sub New(pFName as String, pLName as String, pGrade as String) _firstName = pFName _lastName = pLName _grade = pGrade End Sub Public Property FirstName as String Get Return _firstName End Get Set (value as String) _firstName = value End Set End Property Public Property LastName as String Get Return _lastName End Get Set (value as String) _lastName = value End Set End Property Public Property Grade as Integer Get Return _grade End Get Set (value as Integer) _grade= value End Set End Property End Class
Then to create it, you'd do:
vb Code:
Dim s as New Student("Bob", "Jones", 75)




Reply With Quote