HI,
the string concatenation operator in basic is the "&"
instead of
Code "G01 X_Distance F.10"
you want
Code "G01 X" & X_Distance & " F.10"
But that is not yet quite good enough as X_Distance can turn into a string that has exponents etc. within it...
To solve that, I have a little helper routine that I use for this:
Function GCN(ByVal VBNum) As String
' GCodeNumber: a small util to take a double, format it and return it as a string
' this is needed so that all numbers put into strings that will be sent to Code will not
' have things of the form: X0.123456e-9 - which is not legal gcode format
GCN = Format(VBNum, "#########0.000000") ' 6 sig digits to right of decimal point should be enough
End Function ' GCN
so I would have written the initial line as
Code "G01 X" & GCN(X_Distance) & " F.10"
Dave