Question on VB MOD function
I am trying to manipulate the weight from a scale. The MOD function does not seem to work. To troubleshoot I created a very simple script:
TestNumber = 123.456
TestInt = int(TestNumber)
msgbox TestInt 'Result 123
TestMod = TestNumber Mod 1
msgbox TestMod 'Result 0 Expected 456
Am I using the MOD function incorrectly?
-
A little more about the problem that I am trying to solve. The weight from the weigh scale needs to be converted to 5 digits. EG 2.5 > 02510
I am trying to create a script to accomplish this on the OnProcessData event of the Bar code's weight sub string. Am I heading in the right direction?
This is an internal use UPCA bar code the first 6 digits are the product code and the next 5 digits are the weight.
0 -
The MOD function is for modulo division. It returns the remainder of a number divided by another e.g. 11 mod 3 = 2.
If you're just looking to isolate the decimal portion of your number do this:
TestNumber = 123.456
decimalNumber = TestNumber - int(TestNumber)
1 -
Thanks Adam :)
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
3 Kommentare