Yes, agree with you, works funny with addition (did not expect it - expected FormatNumber() to return a number) . I might be mis-interpreting the subtraction, multiplication & division results.
Code:
Function testNumber()
abc = FormatNumber(0.40545, 4, -1)
def = FormatNumber(0.40545, 4, -1)
ghi = abc + def
jkl = abc - def
mno = abc * def
pqr = abc / def
Debug.Print "The first number : " & abc
Debug.Print "The second number : " & def
Debug.Print "The addition : " & ghi
Debug.Print "The subtraction : " & jkl
Debug.Print "The multiplication : " & mno
Debug.Print "The division : " & pqr
End Function
The result :
Code:
The first number : 0.4055
The second number : 0.4055
The addition : 0.40550.4055
The subtraction : 0
The multiplication : 0.16443025
The division : 1
Code:
Function testNumber_1()
Dim abc As Double
Dim def As Double
Dim ghi As Double
Dim jkl As Double
Dim mno As Double
Dim pqr As Double
abc = FormatNumber(0.40545, 4, -1)
def = FormatNumber(0.40545, 4, -1)
ghi = abc + def
jkl = abc - def
mno = abc * def
pqr = abc / def
Debug.Print "Test_1_The first number : " & abc
Debug.Print "Test_1_The second number : " & def
Debug.Print "Test_1_The addition : " & ghi
Debug.Print "Test_1_The subtraction : " & jkl
Debug.Print "Test_1_The multiplication : " & mno
Debug.Print "Test_1_The division : " & pqr
End Function
The result :
Code:
Test_1_The first number : 0.4055
Test_1_The second number : 0.4055
Test_1_The addition : 0.811
Test_1_The subtraction : 0
Test_1_The multiplication : 0.16443025
Test_1_The division : 1
Wish we could find some explanation.
Thanks