Greetings, I have a simple question/request for clarification on classes and modules. My very simple grass roots understanding is that classes do stuff and modules call classes and pass things to classes. In this exercise I have been tasked with creating an Account class that holds and balance, which comes from a module that inputs the initial balance into the account. I have finally gotten all the error's to go away except one. When I try to pass an initial balance from the module I get an error that states "Too many arguments to 'Public Sub New()'" Can anyone shed some light on what I am doing wrong. I think everything is in order, but obviously I'm missing something. Thanks.
CODE
Module AccountTest
Sub Main()
Dim Account1 As New Account(10) 'this should give Account1 a balance of 10??
Dim account2 As New Account(20) 'this should give Account2 a balance of 20??
Console.WriteLine("Account1 balance = " & Account1.Balance)
Console.WriteLine("Account2 balacne = " & account2.Balance)
End Sub
End Module
My Account class
CODE
Public Class Account
' make a private variable to hold the value of the balance
Private Balancevalue As Integer
Public Sub New_Account(ByVal initialbalance As Integer) 'this value will be given when this class is called
'i.e. "Dim Account As New Account(50) 50 would be the initialbalance variable
If initialbalance > 0 Then 'if the ammount is greater than 0
Balance = initialbalance
End If
End Sub
Public Sub debit(ByVal subtract As Integer)
If subtract <= Balance Then ' if the debit is less than the balance
Balance = Balance - subtract 'the debit amount
End If
End Sub
Public Sub credit(ByVal add As Integer)
Balancevalue = Balance + add 'add this amount to the existing balance
End Sub
Public Property Balance() As Integer
Get 'returns the account balance
Return Balancevalue
End Get
Set(ByVal value As Integer) 'sets the balance
Balancevalue = value
End Set
End Property
End Class