1) How come when I try to do a formula like,
50 * (3/100), vb returns 2 and not 1.5? How can I make it return 1.5? I know it is rounding, but I can't figure out how to stop it from doing so...
Printable View
1) How come when I try to do a formula like,
50 * (3/100), vb returns 2 and not 1.5? How can I make it return 1.5? I know it is rounding, but I can't figure out how to stop it from doing so...
It works for me if I declare the variable to hold the result as a double.
Hope this helps.Code:
Private Sub Command1_Click()
Dim dbl_rec As Double
dbl_rec = 50 * (3 / 100)
MsgBox Val(dbl_rec)
End Sub
Just a nit, but Val is not needed in this case. Val converts string to numbers.
I was using a long varaible to hold the value. When I set it to double, I got my desired result. Thanks...