Hello Guest it is April 23, 2024, 05:25:37 PM

Author Topic: VB compile error: syntax error  (Read 4062 times)

0 Members and 1 Guest are viewing this topic.

Re: VB compile error: syntax error
« Reply #10 on: June 07, 2020, 04:00:38 PM »
Thanks for that but still getting the same error albeit now on line 17. Very strange that it runs on your setup but not on mine.

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: VB compile error: syntax error
« Reply #11 on: June 08, 2020, 01:22:56 AM »
ok made a different Version witch uses MsgBox instead of MachMsg

Code: [Select]
' Auto zero all axes Or just tool length

CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state


'old version witch did not work *********************************************************
' Define constant for MachMsg dialog types
'MachMsgTypeYesNo = 4

' Define constant for MachMsg return codes
'MachMsgReturnYes = 6
'MachMsgReturnNo = 7

' Display a Yes or No dialog
'Ret = MachMsg("Zero Z axis only?", "Zero Z axis only or all axes", MachMsgTypeYesNo)
'****************************************************************************************


' Define constant for MsgBox dialog types
MsgBoxTypeYesNo = 4

' Define constant for MachMsg return codes
MsgBoxReturnYes = 6
MsgBoxReturnNo  = 7

' Display a Yes or No dialog
Ret = MsgBox ("Zero Z axis only?", MsgBoxTypeYesNo , "Zero Z axis only or all axes")


If Ret = MsgBoxReturnYes Then

Message "(Starting Z Zero...)"
If GetOemLed (825)<>0 Then 'Check to see if the probe is already grounded or faulty
Message "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if applicable
End If

DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P3" 'this 3 sec. delay to get from computer to hold probe plate in place
Code "G90 G31Z-25 F100" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the exact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend

' Define some constants
ZaxisDRO = 2
' Set Z Axis DRO to 1.234 (plate thickness)
SetOEMDRO(ZaxisDRO, 1.234)

Sleep 200 'Pause for Dro to update
Code "G1 Z1. F50" 'put the Z retract height you want here, must be greater than the touch plate thickness
While IsMoving ()
Wend
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Code "G4 P3" 'Delay to allow reading of status bar

Else
If Ret = MsgBoxReturnNo Then
Message "(Starting X-Y Corner setting...)"

Rem VB Script For probing X axis

Message "(Jog CNC near centre and 5mm inside the hole, then click OK)"
XCurrent = GetDro(0)
YCurrent = GetDro(1)
Code "G4 P3" 'this 3 sec. delay to get from computer to hold probe plate in place
Code "F100"

Rem Probe Left
XNew = XCurrent -50 'probe 50mm to left
Code "G31 X" &XNew
While IsMoving() ' wait for the move to finish
Wend
XPos1 = GetVar(2000) 'get the probe touch location
Code "G0 X" &XCurrent 'rapid move back to start point

Rem Probe Right
XNew = XCurrent +50 'probe 50mm to right
Code "G31 X" &XNew
While IsMoving()
Wend
XPos2 = GetVar(2000)
XCentre = (XPos1 + XPos2)/2 'centre is midway between XPos1 and XPos2
Code "G0 X" &XCentre ' rapid move to x centre location

Rem Probe up
YNew = YCurrent +50
Code "G31 Y" &YNew
While isMoving()
Wend
YPos1 = GetVar(2001)
Code "G0 Y" &YCurrent

Rem Probe down
YNew = YCurrent -50
Code "G31 Y" &YNew
While isMoving()
Wend
YPos2 = GetVar(2001)
YCentre = (YPos1 + YPos2)/2
Code "G0 Y" &YCentre 'rapid move to y centre location
While isMoving()
Wend

Message "(Starting Z Zero...)"
Code "G0 Z20"
Code "G0 X20Y20"

If GetOemLed (825)<>0 Then 'Check to see if the probe is already grounded or faulty
Message "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if applicable
End If

DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P3" 'this 3 sec. delay to get from computer to hold probe plate in place
Code "G90 G31Z-25 F100" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the exact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend

' Define some constants
ZaxisDRO = 2
' Set Z Axis DRO to 1.234 (plate thickness)
SetOEMDRO(ZaxisDRO, 1.234)

Sleep 200 'Pause for Dro to update
Code "G1 Z1. F50" 'put the Z retract height you want here, must be greater than the touch plate thickness
While IsMoving ()
Wend
Message "(Z axis is now zeroed)" 'puts this message in the status bar

Code "F" &FeedCurrent  'restore starting feed rate
DoOEMButton (1008)
DoOEMButton (1009)
End If
End If

If CurrentAbsInc = 0 Then 'If G91 was in effect before then return to it
Code "G91"
End If

If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
Code "G0"
End If


anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: VB compile error: syntax error
« Reply #12 on: June 08, 2020, 11:12:18 AM »
Fantastic! Thank you so much. It worked on my laptop (Windows 10) and then on my machine (Windows XP). Needs a little fine tuning to the plate thickness etc but works ok. Thanks again.