What is the best way to perform division with quotient and remainder in VBA ?
I want to divide 7 by 3 and want to get Quotient as 2 and Remainder as 1..... I am reading a lot of articles and they talk about Banking rounding , integer rounding etc. All this is getting confusing..........What is the best way of accomplishing this ?
1. For integer quotient i can use 7 \ 3 , but some articles says it might lead some unpredictable results.
2. For remainder i can use MOD(7,3) which gives me 1 , but again some articles says it might lead some unpredictable results.
3. Also when i write VBA code and manually do 7 \ 3 it works , but when i do it using EVALUATE method it will not work and gives error.
String S = VAR1 \ VAR2 then EVALUATE(S) ---- gives error.
String S = VAR1 / VAR2 then EVALUATE(S) ---- works fine.
Any help witll be appreciated. My aim is to perform traditional mathematics and get the quotient and remainder..
I did the below -
Dim Var1 as Integer
Dim Var2 as Intger
Dim Var3 as Double
Var 1 = 7 / 2 ====> it will give me 4 but i need it to give 3.
Var 2 = 7 MOD 2 ===> it is correctly giving me 1.
Bookmarks