Go Back   Computer Forums > General Computing > Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 12-05-2004, 10:58 PM   #1
Baseband Member
Join Date: Aug 2004
Posts: 25
Default Visual Basic .net woes

I'm designing a small program to display the factors of the number.
Currently i'm using \ division and Mod to get the remainder.

chan1 = Result \ 20
If Result < 20 Then
chan1 = 0
End If
rema1 = Result Mod 20

The program takes a number (Result in this case) and divides it by a denomination (20 in this case) and stores the result in chan1.
If Result is less than the denomination then chan1 becomes 0.
It then Mod's Result over 20 to get the remainder and stores this in rema1.
In the next phase chan1 becomes chan2.
20 becomes 10 as that is the next denomination I am checking for.
And rema1 becomes rema1.

Later on I display the amount of denominations like this
Console.WriteLine((chan1) & " x 20")
And this goes down the list from 20 through till 0.01.

What I'm aiming for is a result like this

Result = 35

1 x 20
1 x 10
1 x 5
0 x 2

The problem i'm having is that even though i'm using \ i'm still getting decimal answers for chan4 which deals with Denom of 2.
Result = 38.88
1 x 20
1 x 10
1 x 5
2 x 2
2 x 1
1.76 x .50

In the case of Denom 2 and 1 it rounds it up which it shouldn't do.
In the case of .50 downwards it gives me decimal 'chans'.

I've tried a few things to fix this and I'm really stuck with the whole thing.
If you've got any suggestions or if I haven't explained myself please leave a post and I'll try and elaborate.
Planescape is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 05:55 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0