PDA

View Full Version : decimal turning into comma? vba



Proctor
2nd Jul 2010, 06:57 pm
Hello: I created a program that's been working perfect; however, I recently placed it on a machine and it wasn't working and so of coarse I debugged it and found out that when it's getting the length of the spline, for some reason placing a comma in where there use to be a decimal e.g 5.123 becomes 5,123. it's very strange.

here's the bit of code that's running:



If TypeOf ssobject Is AcadSpline Then
Set MySpline = ssobject
MyLineType = MySpline.Linetype
'THIS SCRIPT SENDS IN PARAMS and calls A LISP FUNCTION TO CALCULATE THE LENGTH OF A SPLINE
'WASNT ABLE TO FIND LENGTH W/ VBA SO HAD TO MAKE CALL LISP FUNCTION vlax-curve-getdistatparam to get it.
With ThisDrawing
ThisDrawing.SetVariable "USERR1", sVar
'load lisp
.SendCommand "(vl-load-com)" & vbCr
'call lisp function and pass in params. return length of spline
strCom = "(setvar " & Chr(34) & "USERR1" & Chr(34) & Chr(32) & "(vlax-curve-getdistatparam (vlax-ename->vla-object (handent " & Chr(34) & ssobject.Handle & Chr(34) & ")) (vlax-curve-getendparam (vlax-ename->vla-object (handent " & Chr(34) & ssobject.Handle & Chr(34) & ")))))" & vbCr
.SendCommand strCom
MyLineLength = .GetVariable("USERR1")
End With
End if


The line in red is when it gets the length of the spline and i see the comma instead of the decimal.

Thanks for your help,
Proctor

MSasu
2nd Jul 2010, 07:03 pm
Please check Control Panel --> Regional And Language Options --> Customize... for that station; most probably the decimal separator symbol is set to comma.

Regards,

Proctor
2nd Jul 2010, 07:30 pm
msasu ...that resolved it!!! Thank you so much for letting me know about this setting!!!

Proctor

MSasu
2nd Jul 2010, 07:33 pm
You're welcome! Glad to help you.

But my suggestion is to add a protection in your code for such cases (i.e. a custom function for conversion string-to-double).

Regards,

Proctor
6th Jul 2010, 03:00 pm
That is a good suggestion....I will do that.

Thanks again,
Proctor