Now that we have added some functionality to our class it is time to instantiate objects from the class ''blueprint''.
== Accessing Object Properties and Methods ==
Now that we know how to write a class and instantiate objects from the class, we now need to know how to call the methods on the methods we created in the class. First, you will recall that we created Get and Set functions the data members of our class. Because we did this, we can change and access these properties simply by reference them as we would any other property. For example:
<pre>
Dim objBankAccount As New clsBankAccount()
objBankAccount.AccountName = "John Smith"
objBankAccount.Balance = 1230
MessageBox.Show(objBankAccount.AccountName & " has a balance of " & CStr(objBankAccount.Balance))
</pre>
The above code excerpt assigns values to the AccountName and account balance properties of our object. It then references the properties in order to display a string with reads "John Smith has balance of 1230" in a MessageBox.
We can also call our subtractFee() method as follows:
<pre>
Dim objBankAccount As New clsBankAccount()
Dim intNewbalance As Integer
objBankAccount.AccountName = "John Smith"
objBankAccount.Balance = 1230
intNewbalance = objBankAccount.subtractFee()
MessageBox.Show(objBankAccount.AccountName & " has a balance of " & CStr(objBankAccount.Balance))
</pre>
The result will be a message which reads "John Smith has balance of 1225", since the account fee has now been subtracted from the balance.