|
-
Apr 22nd, 2002, 05:56 AM
#1
Thread Starter
Junior Member
Denomination Calc
Hi all,
Probably a bit easy but I can't seem to get it to work. How do I go about calculating what denominations I need to make up a money total in VB? e.g. £12.35...how do I calculate that it would need 12 pound coins, 3 ten pence coins, and 1 five pence coin?
I know it has something to do with mod and division, but I can't get it to work.
Any help would be greatly appreciated,
littlefitzer
-
Apr 22nd, 2002, 06:01 AM
#2
Hyperactive Member
You would use 12.35 div 1 to get the number of pound coins
You would use 12.35 mod 1 to get the .35 left over
Then repeat the mod/division process on the remaining money.
-Show me on the doll where the music touched you.
-
Apr 22nd, 2002, 06:22 AM
#3
Thread Starter
Junior Member
Thanks...but..
Thanks very much, but could you show me a brief code example as I keep getting compile errors when I use div?
Thanks again.
-
Apr 22nd, 2002, 03:15 PM
#4
Fanatic Member
use a "\" instead of "div". It's integer divison
I checked on some stuff and found that "\" may not work with decimals, you can always do int(12.35/1) or whatever is nesscessary d
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Apr 23rd, 2002, 02:55 AM
#5
Thread Starter
Junior Member
-
Apr 23rd, 2002, 08:43 AM
#6
Frenzied Member
Use Single or Doubles to hold non integers.
You could get the fractional part by
Fraction = Amount - Int(Amount)
Then Xvalue = Fraction * 10
TenPenceCoins = Int(Xvalue)
Then Xvalue = Int(Xvalue - TenPenceCoins)
Use a long for OnePenceCoins
Then OnePenceCoins = Xvalue*10
FivePencecoins = OnePenceCoins \ 5 (Integer division).
OnePenceCoins = FivePenceCoins Mod 5
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|