The "Change Solution" Help Needed

Reply

Join Date: Oct 2007
Posts: 89
Reputation: leroi green is an unknown quantity at this point 
Solved Threads: 0
leroi green leroi green is offline Offline
Junior Poster in Training

The "Change Solution" Help Needed

 
0
  #1
Feb 25th, 2008
hello all,

been working on this assignment with the VB 2005 book for about a week now and i don't really understand where to go next. it's under lesson C exercise 3 where i have to calculate the amount of change and how many dollars, then quarters (dimes, nicks, pennies) that i have to give the customer.

i know that i need some type of if then statement but i'm not sure where to go with it and my program now is just locking up my PC. Help please.

oh and when you show me. tell me why i do it this way because it will really help me understand more.

thanx guys/gals

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Public Class MainForm
  2.  
  3. Dim TotalChange As Double
  4.  
  5.  
  6. Private Sub xButtonExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xButtonExit.Click
  7. Me.Close()
  8.  
  9. End Sub
  10.  
  11. Private Sub xButtonClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xButtonClear.Click
  12. 'clear all fields and focus back to amount owed
  13. Me.xAmountOwedText.Text = String.Empty
  14. Me.xAmountPaidText.Text = String.Empty
  15. Me.xDollarsCalc.Text = String.Empty
  16. Me.xQuartCalc.Text = String.Empty
  17. Me.xDimeCalc.Text = String.Empty
  18. Me.xNickCalc.Text = String.Empty
  19. Me.xPennyCalc.Text = String.Empty
  20.  
  21. Me.xAmountOwedText.Focus()
  22.  
  23. End Sub
  24.  
  25. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xCalculateButton.Click
  26. Dim Dolla As Integer
  27. Dim Quart As Integer
  28.  
  29. 'calculate the total change and assign to the correct text boxes
  30. TotalChange = Val(Me.xAmountPaidText.Text) - Val(Me.xAmountOwedText.Text)
  31.  
  32. Integer.TryParse(Me.xDollarsCalc.Text, Dolla)
  33. If Dolla >= 1 Then
  34. Dolla = Dolla / 1
  35. End If
  36.  
  37. Integer.TryParse(Me.xQuartCalc.Text, Quart)
  38. If TotalChange > 0.25 Then
  39. Quart = Me.xDollarsCalc.Text / 0.25
  40. End If
  41.  
  42. 'display message, tax and name
  43. Me.xMessageLabel.Text = "The change owed to the customer is " & Format(TotalChange, "currency")
  44.  
  45. End Sub
  46. End Class
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 89
Reputation: leroi green is an unknown quantity at this point 
Solved Threads: 0
leroi green leroi green is offline Offline
Junior Poster in Training

Re: The "Change Solution" Help Needed

 
0
  #2
Feb 25th, 2008
so in the end it if i owe $23.76, it should look like:

Dollars Quarters Dimes Nickels Pennies
23 3 0 0 1

Any ideas?
Last edited by leroi green; Feb 25th, 2008 at 12:52 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC