Phil,
That's odd - below is a literal paste of a code fragment I just ran in mach to check -
Option Explicit
Dim X_Distance As Double
' entry point from mach
X_Distance = GetUserDRO (2011)
Code "G04 P.25"
MsgBox "hit OK to do " & Chr(13) & "G01 X" & GCN(X_Distance)
Code "G01 X" & GCN(X_Distance)
Exit Sub
Function GCN(ByVal VBNum) As String
' GCodeNumber: a small util to take a VB double, format it and return it as a string
' this is needed so that all numbers ptu into strings that will be sent to CodeQ or CodeQW will not
' have things of the form: X0.123456e-9 - which is not legal gcode format
GCN = Format(VBNum, "#########0.00")
End Function ' GCN
Only difference was that I changed the format string to have only 2 digits to right of decimal as you requested.
I also added a debug msgbox just to see the string - looks fine, causes mach movement when the G01 is issued.
Note that I always use "option explicit" - that forces all variables to be declared before use.
This saves me from a typo creating a new variable of type variant on the fly. This should not make a difference to the code though.
Dave