(in europe we use sign decimal point (,) as decimal separator)
Yes, I know that. Hungary is in Europe...
(I am living in Budapest, as you can see in my signature)
Then in bottom window for following variables I see
a = 1E-02
Where is it? Do you see it in the Basic IDE? In the "variable watch window"?
a = 0.01 (StarBasic variable input format) = 0,01 (European decimal format) = 1*10^(-2) (scientific format) = 1E-2 (scientific format for computers)
The Format() function will return with a string, but not a number.
The user defined Round() function will return with a numeric value. (But you can embed the Format() function into an another custom function:
Code: Select all
sub Main
Dim a As Double
Dim b As Double
Dim c As Double
Dim s as string
a = 1000
b = 234
c = a - b
s = Round_and_Format(c, 2)
'try it with 0 and negative values too...
msgbox s
end sub
Function Round_and_Format(num as double, dec as integer) as string
Dim FormatCodeStr as string
Dim Rounded As Double
Dim i as integer
FormatCodeStr = "0"
Rounded = Int(num * 10 ^ dec + 0.5) / 10 ^ dec
if dec > 0 then
FormatCodeStr = FormatCodeStr + "."
for i = 1 to dec
FormatCodeStr = FormatCodeStr + "0"
next i
endif
Round_and_Format = Format(Rounded, FormatCodeStr)
End Function