The class has some issues. For one thing, those shouldn't be properties, they should be functions. You want to take two arguments and return a single value. A property is used to set a member variable, or return a member variable in a class instance. What you should have for AddMethod is this:
Except that that isn't right, either. I see you have Balance as a class member. That should be exposed as a ReadOnly property (no Set method at all). That also makes the AddMethod a bit different depending on what it is supposed to do. The function I wrote does what your property was doing, but that doesn't seem right, because what is the purpose of a balance member in a class called CashRetgister if the AddMethod function does nothing but add two numbers together and return the result? It seems more likely that what you want is something like this:Code:Public Function AddMethod(firstValue as double, secondValue as double) As Double return firstValue + secondValue End Function
The form would still need to have an instance of the CashRegister class as a member for you to use it. You'd then properly convert the strings from the Textbox and pass them as the argument to the AddMethod.Code:Public ReadOnly Property TheBalance As Double Get Return Balance End Get End Property Public Sub AddMethod(newValue as Double) Balance += newValue End Sub






Reply With Quote
