Multiple of

J

J

I'm trying to determine if a number is a multiple of another number.

For instance, I have a table set up that shows the following:
Widget Increment
A 5,000
B 10,000
C 25

"A" Widgets can only be ordered in increments of 5,000. "B" widgets can
only be ordered in increments of 10,000 and "C" widgets can only be ordered
in increments of 25.

What's the best way to check the quantity entered and make sure it's in the
appropriate increment?

At first my thought was to take the quantity ordered of "A" (ex: 25,000) and
divide by the allowed increment for "A" (5,000) and check the result (in this
example = 5) and then check to see if the result is a 'whole number', but I
couldn't get that to work. I tried using VarType.

Any suggestions??

Thanks!
 
M

Marshall Barton

J said:
I'm trying to determine if a number is a multiple of another number.

For instance, I have a table set up that shows the following:
Widget Increment
A 5,000
B 10,000
C 25

"A" Widgets can only be ordered in increments of 5,000. "B" widgets can
only be ordered in increments of 10,000 and "C" widgets can only be ordered
in increments of 25.

What's the best way to check the quantity entered and make sure it's in the
appropriate increment?

At first my thought was to take the quantity ordered of "A" (ex: 25,000) and
divide by the allowed increment for "A" (5,000) and check the result (in this
example = 5) and then check to see if the result is a 'whole number', but I
couldn't get that to work. I tried using VarType.


Try using:
(Quantity Mod Increment) = 0
 
G

George Nicholson

The Mod operator returns the remainder from a division.

************
x = 25000
y = 5000

If x Mod y = 0 Then
'Correct increment (no remainder).. Do nothing.
Else
MsgBox x & " is not an increment of " & y
End If
*************
Read the VB Help entry to make sure its querks won't cause you problems.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top