Function NumberToString(num As Variant) As String
%REM
Строит на основании числа строку с разделителем
%END REM
On Error Goto TRAP
Dim str1 As String
str1 = Cstr(num)
Dim str2 As String
If Instr(str1, ",") Then
str2 = "," & Strright(str1, ",")
str1 = Strleft(str1, ",")
End If
While Len(str1)>0
str2 = Right(str1, 3) & " " & str2
If Len(str1)>3 Then
str1 = Left(str1, Len(str1)-3)
Else
str1= ""
End If
Wend
str2 = Replace(str2, " ,", ",")
NumberToString = str2
Exit Function
TRAP:
Error Err, Error & " at line " & Erl & " of NumberToString"
Exit Function
End Function