May 7th, 2012, 08:22 PM
Join Date: May 2012
Time spent in forums: 32 m 20 sec
Reputation Power: 0
Calling a Function From a class
Ok strictly i have a simple class with a simple function in it separate from the form's class. I am having difficulties getting the code rite for calling the function from the class.
Its for a small little "ATM" program I'm doing for a class that requires me to load some data into a collection call that data into the class then show balance and allow for deposits and withdrawals.
Public Class Customer
Public Pin As String
Public Name As String
Public Balance As Double
Public Sub New(ByVal Pin As Integer, ByVal Name As String, ByVal Balance As Double)
Me.Pin = Pin
Me.Name = Name
Me.Balance = Balance.ToString("c")
Public Function Deposit(ByVal Amount As Double)
Balance = Balance + Amount
Public Function Withdraw(ByVal Amount As Double)
If Amount < Balance Then
Balance = Balance - Amount
Return MessageBox.Show("Amount desired exceeds funds")
Public Function ShowBalance()
Return MessageBox.Show(Balance & "Is the accounts current balance")
There is the code for the class. I just need to figure out how to call a function from Class: Customer to Class: Form1
I can already load the data from the collection into a variable of type customer. So my data is already loaded in and happy. I just need the calling of the functions.
Any and all help is appreciated.
I figured out what i did wrong 3 minutes after i posted this. Thanks to anyone who looked at it and was about to give their own thoughtful answer though!