Welcome to Dream.In.Code
Become a VB Expert!

Join 137,234 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,684 people online right now. Registration is fast and FREE... Join Now!




Change Calculator - Delete other post plz

 
Reply to this topicStart new topic

Change Calculator - Delete other post plz, Origianal topic is messed up, please reply to this topic as it shows m

jjuneau
18 Feb, 2007 - 08:28 PM
Post #1

New D.I.C Head
*

Joined: 15 Feb, 2007
Posts: 16


My Contributions
The other Change Calculator post should be deleted, this new post was made to reflect my progress and to prevent any confusion.


Here is the original problem:
A form will accept two types of input then perform a calcuation. The two inputs are,

1- How much money a customer owes me
2. How much money the customer paid/tendered

The program must then calculate the change that is due, but it must be displayed in 5 fields..

example -

$5.50 due, customer pays $10
Program must show -

Dollars owed - 4
Quarters owed - 2
Dimes owed - 0
Nickeles owed - 0
Pennies owed - 0

Of course, the input amounts will vary and the program needs to be able to calculate various inputs.


I coded my calculation button with the code below. However, the calculation process does not seem to make it past the first "Case" statement. The "mydollars" value seems to only hold and display the number one and it appears the calculation process just stops, because no other fields display any information. And most notably, the "mydollars" field doesn't go any higher than 1.

Maybe one of you guru's can tell me what i did wrong here:

'Begin change calculation
While changedue2 > 0
Select Case changedue2
'Dollar calculation
Case Is >= 1
myDollars = +1
changedue2 = -1
'Displays variable values on form
DollarField.Text = myDollars
'Quarters
Case Is >= 0.25
myQuarters = +1
changedue2 = -0.25
QuarterField.Text = myQuarters
'Dimes
Case Is >= 0.1
myDimes = +1
changedue2 = -0.1
DimeField.Text = myDimes
'Nickels
Case Is >= 0.05
myNickles = +1
changedue2 = -0.05
NickelField.Text = myNickles
'Pennies
Case Is >= 0.01
myPennies = +1
changedue2 = -0.01
PennyField.Text = myPennies

'Error Handler
Case Else
MessageBox.Show("Something went wrong")
End Select
End While
User is offlineProfile CardPM
+Quote Post

KeyWiz
RE: Change Calculator - Delete Other Post Plz
19 Feb, 2007 - 10:08 PM
Post #2

D.I.C Regular
Group Icon

Joined: 26 Oct, 2006
Posts: 428


Dream Kudos: 125
My Contributions
CODE


'Begin change calculation
While changedue2 > 0
    Select Case changedue2
        'Dollar calculation
        Case Is >= 1
            myDollars = myDollars + 1
            changedue2 = changedue2 - 1
            'Displays variable values on form
            DollarField.Text = Str(myDollars)
        'Quarters
        Case Is >= 0.25
            myQuarters = myQuarters + 1
            changedue2 = changedue2 - 0.25
            QuarterField.Text = Str(myQuarters)
        'Dimes
        Case Is >= 0.1
            myDimes = myDimes + 1
            changedue2 = changedue2 - 0.1
            DimeField.Text = Str(myDimes)
        'Nickels
        Case Is >= 0.05
            myNickles = myNickles + 1
            changedue2 = changedue2 - 0.05
            NickelField.Text = Str(myNickles)
        'Pennies
        Case Is >= 0.01
            myPennies = myPennies + 1
            changedue2 = changedue2 - 0.01
            PennyField.Text = Str(myPennies)
            
        'Error Handler
        Case Else
        MessageBox.Show ("Something went wrong")
    End Select
Wend


This post has been edited by KeyWiz: 19 Feb, 2007 - 10:14 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:55PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month