Prev | Current Page 77 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"

New()
End Sub
35
C H A P T E R 3
e8376d3cc8796c3240d60804b9c401fb
'Properties
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal value As String)
mName = value
End Set
End Property
Public Property CustomerID() As Integer
Get
Return mCustomerID
End Get
Set(ByVal value As Integer)
mCustomerID = value
End Set
End Property
'Methods
Public Function SaveCustomerToDB() As Boolean
'Put code for this function here.
'For now, return success
Return True
End Function
End Class
This class declaration defines a Customer class. The access modifier in front of the Class
keyword, in this case Public, controls the visibility of the type from inside and outside of the
assembly. The class Customer is publicly accessible, which means that you can create instances
of this class. The Customer class contains two fields, a constructor, two properties, and one
function. The property methods allow read/write access to the fields, and the function is used
to save the customer to a database.
Constructors
Constructors are called when an object is created. There are two types of constructors: default
constructors and instance constructors. A class can have only one default constructor, and it
can have no parameters. The name of the default constructor is New().


Pages:
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
Tango Olsztyn katalog stron katalog stron kominek śmieszne dowcipy