1
VB and the development of wizards / Macro Help
« on: December 18, 2015, 10:13:17 AM »
Need help with the below program, can someone tell me what's wrong?
oldtool = GetCurrentTool() 'Get the current tool postion
newtool = GetSelectedTool() 'Get the new tool position
if newtool < 1 or newtool > 8 Then 'make sure new tool isnt a number
DoOemButton(1003) 'below 1 or above 8
MsgBox("Tool Number Not Valid")
End
End if
if oldtool = newtool Then 'if new tool is same as current tool
End 'quit and do nothing
End if
if newtool = 1 Then 'if tool number 1 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#1) 'oem trig #1 is tool position 1
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 2 Then 'if tool number 2 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#2) 'oem trig #2 is tool position 2
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 3 Then 'if tool number 3 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#3) 'oem trig #3 is tool position 3
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 4 Then 'if tool number 4 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#4) 'oem trig #4 is tool position 4
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 5 Then 'if tool number 5 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#5) 'oem trig #5 is tool position 5
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 6 Then 'if tool number 6 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#6) 'oem trig #6 is tool position 6
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 7 Then 'if tool number 7 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#7) 'oem trig #7 is tool position 7
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 8 Then 'if tool number 8 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#8) 'oem trig #8 is tool position 8
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
SetCurrentTool(newtool)
End
oldtool = GetCurrentTool() 'Get the current tool postion
newtool = GetSelectedTool() 'Get the new tool position
if newtool < 1 or newtool > 8 Then 'make sure new tool isnt a number
DoOemButton(1003) 'below 1 or above 8
MsgBox("Tool Number Not Valid")
End
End if
if oldtool = newtool Then 'if new tool is same as current tool
End 'quit and do nothing
End if
if newtool = 1 Then 'if tool number 1 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#1) 'oem trig #1 is tool position 1
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 2 Then 'if tool number 2 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#2) 'oem trig #2 is tool position 2
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 3 Then 'if tool number 3 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#3) 'oem trig #3 is tool position 3
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 4 Then 'if tool number 4 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#4) 'oem trig #4 is tool position 4
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 5 Then 'if tool number 5 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#5) 'oem trig #5 is tool position 5
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 6 Then 'if tool number 6 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#6) 'oem trig #6 is tool position 6
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 7 Then 'if tool number 7 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#7) 'oem trig #7 is tool position 7
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
if newtool = 8 Then 'if tool number 8 selected
ActivateSignal(Output2) 'output2 is turret foward
While IsActive(OEMtrig#8) 'oem trig #8 is tool position 8
Wend
Deactivate(Output2) 'turn off output 2
ActiveSignal(Output3) 'output 3 is turret reverse
While IsActive(Input1) 'input 1 is turret clamped
Wend
Code ("G4 P1") 'wait 1 sec to ensure turret clamped
Deactivate(Output3) 'turn off output 3
End if
SetCurrentTool(newtool)
End