944,030 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 4602
  • VB.NET RSS
Oct 24th, 2007
0

Help Needed With OOP Bank Account..VB.Net

Expand Post »
Hi everyone!

At the moment I am working on an OOP bank account program as an assignment in VB.Net.

FYI:It has a credit account class with properties of AccountName, AccountNumber and Balance. The credit account class has two methods - deposit and withdraw. You can overdraw on the credit account, but not on the savings account. If the user tries to overdraw on the savings account, a user defined event displays an error message.

I think I've written the Credit Account and Savings Account classes correctly, but what I'm getting stuck with is the user defined event to display the error message, and I'm getting confused when I try to get it all to work off my GUI. Some buttons and functions work while others kinda don't ...and I'm losing so much sleep over it and it's probably something really minor (to you lol) My interface consists of textboxes(AccName, AccNum & Amount to specify the amount you deposit or withdraw) Radio Buttons (Credit & Savings to choose account type. Deposit & Withdraw to choose transaction) Buttons (Clear, Confirm, Exit) Again, any help, tips, pointers, links or anything that would help or point me in the right direction would be greatly appreciated. Thank you
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
iseedeadpixels is offline Offline
3 posts
since Oct 2007
Oct 24th, 2007
0

Re: Help Needed With OOP Bank Account..VB.Net

Well how can we diagnose the problem without seeing the code. Post it here!
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Oct 24th, 2007
0

Re: Help Needed With OOP Bank Account..VB.Net

Hi everyone!

Yeah sorry about that...maybe posting the code would be a good idea huh?! lol

Sooooo sorry if I post it wrong...

First Class - Credit Account

VB.NET Syntax (Toggle Plain Text)
  1. Public Class Credit_Account
  2.  
  3. Private AccountName As String 'Customer's Account Name
  4. Private AccountNumber As Integer 'Customer's Account Number
  5. Protected Balance As Double 'Customer's Account Balance
  6.  
  7. Public Sub New(ByVal Nm As String, ByVal Bal As Double)
  8. AccountName = Nm
  9. Balance = Bal
  10. End Sub
  11.  
  12. Property AccName() As String
  13. Get
  14. Return AccountName
  15. End Get
  16. Set(ByVal Value As String)
  17. AccountName = Value
  18. End Set
  19. End Property
  20.  
  21. Property AccNumber() As Integer
  22. Get
  23. Return AccountNumber
  24. End Get
  25. Set(ByVal Value As Integer)
  26. AccountNumber = Value
  27. End Set
  28. End Property
  29.  
  30. ReadOnly Property AccountBal() As Double
  31. Get
  32. Return Balance
  33. End Get
  34. End Property
  35.  
  36. Public Overridable Sub Deposit(ByVal Amount As Double)
  37. Balance += Amount
  38. End Sub
  39.  
  40. Public Overridable Sub Withdraw(ByVal Amount As Double)
  41. Balance -= Amount
  42. End Sub
  43. Public Overridable Sub Display()
  44. Console.WriteLine("Name=" & AccountName & ", " & "Balance=" & Balance)
  45. End Sub
  46.  
  47. Public Sub ChangeName(ByVal newName As String)
  48. AccountName = newName
  49. End Sub
  50. ' Initial balance is zero for each new instance
  51. Public Sub New()
  52. Balance = 0
  53. End Sub
  54. End Class

Second Class - Savings Account

VB.NET Syntax (Toggle Plain Text)
  1. Public Class Saving_Account
  2. Inherits Credit_Account
  3.  
  4. Public Sub New(ByVal Nm As String, _
  5. ByVal Bal As Double)
  6.  
  7. MyBase.New(Nm, Bal)
  8.  
  9. End Sub
  10. Public Overrides Sub Withdraw(ByVal Amount As Double)
  11. If Amount <= Balance Then ' Use balance, inherited from base class
  12. MyBase.Withdraw(Amount) ' Call Withdraw, inherited from base class
  13. End If
  14. End Sub
  15.  
  16. Public Overrides Sub Display()
  17. MyBase.Display() ' Call Display, inherited from base class
  18. Console.WriteLine("There are insufficient funds to complete this transaction." & vbCrLf _
  19. & "This account cannot have a negative balance.", "Transaction Error")
  20. End Sub
  21. End Class

Then like I said above, I have my form with buttons, radio buttons and textboxes...I have some code written for my form, but it's all messed up so I thought I'd better not post it

I'm unsure of where the RaiseEvent code is supposed to go to "Raise the user defined error message when the user tries to overdraw on the savings account"...and any hints on what I should be trying to write on my 'Confirm' button, on my form to get everything to work that would be cool...so far, when you click on it, it just deposits money into the credit account and shows the running balance. I'm working on the data validation part but again, some parts don't go while some parts do???!!!! AAAAAAAAAARGH....

Thanks for taking the time to give me some much needed advice...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
iseedeadpixels is offline Offline
3 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: looping thru database results
Next Thread in VB.NET Forum Timeline: Database Encryption





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC