Welcome to Dream.In.Code
Getting VB Help is Easy!

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




CHANGE MAKER

 
Reply to this topicStart new topic

CHANGE MAKER

woamatthew
post 27 Mar, 2008 - 07:01 PM
Post #1


New D.I.C Head

*
Joined: 27 Mar, 2008
Posts: 1

i dont know what i am doing wrong but, the quarters and dimes (so far havnt gotten past this yet) do not work out like they are supposed to work out, can any 1 help? (code below)






CODE

Const quarter As Integer = 0.25
        Const dime As Double = 0.1
        Const nickel As Double = 0.05
        Const penny As Double = 0.001
        Dim bill As Double
        Dim cash As Double
        Const toonies As Double = 2
        Const loonies As Double = 1





        bill = txtbill.Text
        cash = txtcash.Text

        Lblowed.Text = cash - bill

        lblmoney.Text = (Lblowed.Text \ 5) * 5


        lbltooniesa2.Text = "$" & ((Lblowed.Text - lblmoney.Text) \ toonies) * toonies
        lbltooniesa1.Text = (Lblowed.Text - lblmoney.Text) \ toonies

        lbllooniesa2.Text = "$" & ((Lblowed.Text - lblmoney.Text - lbltooniesa2.Text) \ loonies) * loonies
        lbllooniesa1.Text = (Lblowed.Text - lblmoney.Text - lbltooniesa2.Text) \ loonies

        lblquartersa2.Text = "$" & ((Lblowed.Text - lblmoney.Text - lbltooniesa2.Text - lbllooniesa2.Text) / quarter) * quarter
        lblquartersa1.Text = (Lblowed.Text - lblmoney.Text - lbltooniesa2.Text - lbllooniesa2.Text) / quarter


        lbldimesa2.Text = "$" & ((Lblowed.Text - lblmoney.Text - lbltooniesa2.Text - lbllooniesa2.Text - lblquartersa2.Text) / dime) * dime
        lbldimesa1.Text = (Lblowed.Text - lblmoney.Text - lbltooniesa2.Text - lbllooniesa2.Text - lblquartersa2.Text) / dime
User is offlineProfile CardPM

Go to the top of the page

tope10
post 25 Jul, 2008 - 10:27 PM
Post #2


New D.I.C Head

*
Joined: 25 Jun, 2008
Posts: 22



Thanked 2 times
My Contributions


QUOTE(woamatthew @ 27 Mar, 2008 - 08:01 PM) *


I was confused with the control that you used. I thought lblowed, lblmoney, etc.. is a Label but when i read the code this is a text box. when you use the prefix lbl, this pertain to the label control. maybe this is your error, if you used label used the property caption instead of text, when displaying a set of string or character.

example.
this is the code when you used label

lblMessage.caption = "Hello world!"

when textboxes is used...

txtMessage.text = "Hello world!"



CODE

        Const quarter As Double = 0.25
        Const dime As Double = 0.1
        Const nickel As Double = 0.05
        Const penny As Double = 0.001
        Dim bill As Double
        Dim cash As Double
        Const toonies As Double = 2
        Const loonies As Double = 1


        bill = txtbill.Text
        cash = txtcash.Text

        lblOwed.Text = cash - bill

        lblmoney.Text = (lblOwed.Text \ 5) * 5


        lbltooniesa2.Text = ((lblOwed.Text - lblmoney.Text) \ toonies) * toonies
        lbltooniesa1.Text = (lblOwed.Text - lblmoney.Text) \ toonies

        lbllooniesa2.Text = ((lblOwed.Text - lblmoney.Text - lbltooniesa2.Text) \ loonies) * loonies
        lbllooniesa1.Text = (lblOwed.Text - lblmoney.Text - lbltooniesa2.Text) \ loonies

        lblquartersa2.Text = ((lblOwed.Text - lblmoney.Text - lbltooniesa2.Text - lbllooniesa2.Text) / quarter) * quarter

        lblquartersa1.Text = (lblOwed.Text - lblmoney.Text - lbltooniesa2.Text - lbllooniesa2.Text) / quarter


        lbldimesa2.Text = ((lblOwed.Text - lblmoney.Text - lbltooniesa2.Text - lbllooniesa2.Text - lblquartersa2.Text) / dime) * dime
        lbldimesa1.Text = (lblOwed.Text - lblmoney.Text - lbltooniesa2.Text - lbllooniesa2.Text - lblquartersa2.Text) / dime




QUOTE

I made a correction in your code.. The main error of this program is overflow, because the value you supplied in the const variable which is the quarter it has a decimal places, so instead of declaring integer declare it as double data type.

User is offlineProfile CardPM

Go to the top of the page

Zhalix
post 25 Jul, 2008 - 11:01 PM
Post #3


D.I.C Head

**
Joined: 7 May, 2008
Posts: 218



Thanked 9 times
My Contributions


Old thread. Oh well. I noticed something though:

QUOTE(woamatthew @ 27 Mar, 2008 - 09:01 PM) *
CODE
lblmoney.Text = (Lblowed.Text \ 5) * 5


"(Lblowed.Text \ 5) * 5" is a pointless equation. You're saying take this number, divide it by five, and then multiply it by five. Which is the same as the number you started with:

10 / 5 = 2 ...
2 * 5 = 10

Might as well just be saying:
CODE
lblMoney.Caption = lblOwed.Caption
(Or .Text if it's a textbox).

This post has been edited by Zhalix: 25 Jul, 2008 - 11:05 PM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 02:32AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month