448,717 Members | 1,770 Online
Need help? Post your question and get tips & solutions from a community of 448,717 IT Pros & Developers. It's quick & easy.

# MOD Operation

 P: n/a Why does MsgBox 4.25 MOD 1 display 0? I was hoping to get .25. Thanks! Mark Nov 13 '05 #1
4 Replies

 P: n/a Hi, Mark. Modulus division only returns whole numbers, not fractions. HTH. Gunny See http://www.QBuilt.com for all your database needs. See http://www.Access.QBuilt.com for Microsoft Access tips. "Mark" wrote in message news:7Q*******************@newsread3.news.atl.eart hlink.net... Why does MsgBox 4.25 MOD 1 display 0? I was hoping to get .25. Thanks! Mark Nov 13 '05 #2

 P: n/a "Mark" wrote Why does MsgBox 4.25 MOD 1 display 0? I was hoping to get .25. When you round 4.25 to an integer, you get 4. When you divide 4 by 1 you get a result of 4 and a remainder of 0. That's why you get 0. From Access 2003 (Visual Basic 6.3) Help (and the definition of Mod hasn't changed since Access 1.0, AFAIK): "Remarks The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as result. For example, in the following expression, A (result) equals 5. A = 19 Mod 6.7" Nov 13 '05 #3

 P: n/a If you want to show the "fractional part", you could try 4.25 - Int(4.25) Larry Linson Microsoft Access MVP "Mark" wrote in message news:7Q*******************@newsread3.news.atl.eart hlink.net... Why does MsgBox 4.25 MOD 1 display 0? I was hoping to get .25. Thanks! Mark Nov 13 '05 #4

 P: n/a Hi Mark, After having read all of these replies, I thought "OK .. try this..." Dim MyValue as Long MyValue = 4.25 Dim MyNumber As Long MyNumber = (MyValue * 100) Dim MyRemainder as Long MyRemainder = (MyNumber MOD 100) / 100 -- HTH, Don ============================= E-Mail (if you must) My*****@Telus.net Disclaimer: Professional PartsPerson Amateur Database Programmer {:o) I'm an Access97 user, so all posted code samples are also Access97- based unless otherwise noted. ================================================== ========================== ==== I was "anally raped" on a Timeshare deal by Club All Seasons http://worf.usshurdman.com/~calgary/...id=26180&code= , Les Volieres du Quebec, and Club Privilege. In appreciation for that, please feel free to forward SPAM and VIRUSES to: ch**********@bellnet.ca ip*****@hotmail.com in**@volieres.com Don't get mad --- get even! :-) ================================================== ========================== ==== "Mark" wrote in message news:7Q*******************@newsread3.news.atl.eart hlink.net... Why does MsgBox 4.25 MOD 1 display 0? I was hoping to get .25. Thanks! Mark Nov 13 '05 #5

### This discussion thread is closed

Replies have been disabled for this discussion.