After looking at the code I realize that a couple of things are happening.
The VBA SnapToggle will fire before the lisp completes, so lets do this.....
Change the TOS program to this:
(defun C:TOS (10)
nil
)
Now lets change the BeginLisp to this:
Private Sub AcadDocument_BeginLisp(ByVal FirstLine As String)
If StrConv(FirstLine, vbUpperCase) = "C:TOS" Then
ThisDrawing.SnapToggle (Mid$,FirstLine,6,3)
End If
End Sub
and change the SnapToggle to this:
Sub SnapToggle( VarSnapType As Variant)
Dim VarOsmode As Integer
Dim VarAftrek As Integer
Dim VarOsmodeOrg As Integer
VarOsmode = ThisDrawing.GetVariable("osmode")
VarOsmodeOrg = ThisDrawing.GetVariable("osmode")
VarAftrek = 16384
While VarAftrek > VarSnapType
VarAftrek = VarAftrek / 2
If VarOsmode > VarAftrek Then VarOsmode = VarOsmode - VarAftrek
Wend
If VarOsmode = VarSnapType Then VarOsmodeOrg = VarOsmodeOrg - VarSnapType
If VarOsmode < VarSnapType Then VarOsmodeOrg = VarOsmodeOrg + VarSnapType
ThisDrawing.SetVariable ("osmode"), VarOsmodeOrg
End Sub