06 dezembro 2007

Formatando valor por virgula

Function SQLReplace(str)
if str <> "" THen
SQLReplace = Replace(str, ",","")
SQLReplace = Replace(SQLReplace, ".","")
End If
End Function

Function Formata_Valor(valor,tipo)
IF Len(Valor) = 1 THEN
Formata_Valor = 0 & ",0" & Valor
ELSEIF Len(Valor) = 2 THEN
Formata_Valor = 0 & "," & Valor
ELSE
If valor <> "" THen
Formata_Valor = Left(Valor,Len(Valor)-2) & "," & Right(Valor, 2)
End If
END IF
If tipo = 1 then
Formata_Valor = FormatNumber(Formata_Valor,2)
elseif tipo = 2 then
Formata_Valor = FormatCurrency(Formata_Valor)
End IF
End Function