Decimal Separator (, or .?)

Decimal Separator (, or .?)

Anonymous
Not applicable
319 Views
4 Replies
Message 1 of 5

Decimal Separator (, or .?)

Anonymous
Not applicable
I'm working with a VBA macro that passes a number from visual lisp to Excel.
My problem is that, in brazil, we use a comma (,) as separator (one million
is 1000000,00).

So, every time that I pass a numer to excel it looses the decimal places.

Any body knows a way to change the decimal separator in VBA?

Thanks!
0 Likes
320 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
You'll have to save the number to a variable and scan through it in a loop using
the Len and Mud$ functions to pinpoint and replace the seperator. The clip of
code below does exactly what your looking to do except it's searching for the
backslash in a pathname.
-Josh

Dim StringCount As Integer
Dim CopyCount As Integer
Dim testSlash As String
Dim DirectoryInfo As String
If Len(ThisDrawing.Name) > 7 Then
If Mid$(ThisDrawing.Name, 1, 7) = "Drawing" Then
MsgBox "You Must First Save the Drawing to a Name Using the Saveas
Command Before You Can Use Save to Both.", vbCritical
ThisDrawing.SendCommand "saveas "
End
End If
End If
StringCount = Len(ThisDrawing.FullName) - 1
AlternatePathName = "T" & Mid$(ThisDrawing.FullName, 2, StringCount)
AlternatePath = "T" & Mid$(ThisDrawing.Path, 2, Len(ThisDrawing.Path) - 1)
ThisDrawing.Save
If Dir(AlternatePath, vbDirectory) = "" Then
NewDir = "T:\"
DirectoryInfo = ThisDrawing.Path
CopyCount = 4
Do While CopyCount < Len(DirectoryInfo)
testSlash = Mid$(DirectoryInfo, CopyCount, 1)
If testSlash <> "\" Then
NewDir = NewDir & testSlash
ElseIf testSlash = "\" Then
If Dir(NewDir, vbDirectory) = "" Then MkDir NewDir
NewDir = NewDir & testSlash
End If
CopyCount = CopyCount + 1
Loop
MkDir AlternatePath
End If

"André Dantas Rocha" wrote:

> I'm working with a VBA macro that passes a number from visual lisp to Excel.
> My problem is that, in brazil, we use a comma (,) as separator (one million
> is 1000000,00).
>
> So, every time that I pass a numer to excel it looses the decimal places.
>
> Any body knows a way to change the decimal separator in VBA?
>
> Thanks!
0 Likes
Message 3 of 5

Anonymous
Not applicable
Excuse me, that's Mid$ function.

Minkwitz Design wrote:

> You'll have to save the number to a variable and scan through it in a loop using
> the Len and Mud$ functions to pinpoint and replace the seperator. The clip of
> code below does exactly what your looking to do except it's searching for the
> backslash in a pathname.
> -Josh
0 Likes
Message 4 of 5

Anonymous
Not applicable
Thank you very much,

I'll try it and let you know...
0 Likes
Message 5 of 5

Anonymous
Not applicable
André,

Assuming your decimal separator is set to a coma, these two expressions
will return the same value:

Private Sub Command1_Click()
MsgBox "Converting with CDbl: " & CStr(1.2 + CDbl("5,2")) & _
vbLf & "Converting with Val : " & CStr(1.2 + Val("5.2"))
End Sub

Denis

"André Dantas Rocha" a écrit dans le message news:
ef0b1bd.-1@WebX.SaUCah8kaAW...
> I'm working with a VBA macro that passes a number from visual lisp to
Excel.
> My problem is that, in brazil, we use a comma (,) as separator (one
million
> is 1000000,00).
>
> So, every time that I pass a numer to excel it looses the decimal places.
>
> Any body knows a way to change the decimal separator in VBA?
>
> Thanks!
>
0 Likes