2 Replies - 1147 Views - Last Post: 26 July 2008 - 12:01 AM Rate Topic: -----

#1 woamatthew  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-March 08

CHANGE MAKER

Post icon  Posted 27 March 2008 - 08:01 PM

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)






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
 


Is This A Good Question/Topic? 0
  • +

Replies To: CHANGE MAKER

#2 tope10  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-June 08

Re: CHANGE MAKER

Posted 25 July 2008 - 11:27 PM

View Postwoamatthew, on 27 Mar, 2008 - 08:01 PM, said:

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!"


		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.

Was This Post Helpful? 0
  • +
  • -

#3 Zhalix  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 260
  • Joined: 07-May 08

Re: CHANGE MAKER

Posted 26 July 2008 - 12:01 AM

Old thread. Oh well. I noticed something though:

View Postwoamatthew, on 27 Mar, 2008 - 09:01 PM, said:

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:
lblMoney.Caption = lblOwed.Caption
(Or .Text if it's a textbox).

This post has been edited by Zhalix: 26 July 2008 - 12:05 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1