VB.Net 2003 - How do you declare a structure inside a class?

JuniorMint

New member
Joined
Mar 23, 2006
Messages
2
Programming Experience
Beginner
Hello,

I am new to VB.Net programming and I am stuck on an assignment that my instructor just gave to me. I was hoping that someone could give me some pointers on how to solve the following. I must use VB.Net 2003.


Here is how the user interface works:
- you can enter a deposit or withdrawal by selecting the date, the appropriate option button, entering the amount, and pressing Enter.
- you can enter a cheque by selecting the "Cheque" option button, entering the "Payable To:", entering the amount and pressing Enter
- as you enter the values, the Register portion of the page adds a line for each transaction
- if you select Deposit or Withdrawal, you must enter an amount
- if you select Cheque, you must enter a "Payable To" and an amount
Here is what is necessary in your code (as a minimum):
- Implement a class to represent your chequing account. This class must do the following:
- keep the balance
- keep a record of each transaction (up to 100 transactions)
- provide a method to make a deposit
- provide a method to make a withdrawal
- provide a method to enter a cheque

I am confused on how a class can store 100 transactions and keep the balance. The instructor suggested creating a structure with the class. I am not sure how this can be done. Does anyone know how I can achieve this in the simplest way possible. I must use do the minimum which is to use a class. Any ideas? Your help will be greatly appreciated.
Thanks!
 
You declare a nested structure exactly the same way you declare a stand-alone structure except that you put its definition inside the class definition. If the structure is not to be used outside the class then declare it private, otherwise declare it public:
VB.NET:
Public Class SomeClass

    Private Structure NestedStructure
        '...
    End Structure

    '...

End Class
 
Thanks jmcilhinney for the reply.
Do you think this can work if I make a private structure and then create an array(100) of the structure type and then use methods (deposit, withdrawal, cheque) to fill the transactions into the array (all inside the class)?
Does that sound like a good approach?
Thanks.
 
Back
Top