I have a pushbutton that sends data to the serial port. The problem is that the code takes 10-20 seconds to run depending on which PC it is run on. This causes the user to think it's not working and press the pushbutton several more times, which adds to the problem, often causing the PC to hang up.
I'm thinking two things:
(1) Is there code that causes the pushbutton to be inoperable after first pushed, and then operable after the code completes?
(2) Is the "Wait" code the best way to do this or even necessary?
Here's the code for reference:
Thanks!
I'm thinking two things:
(1) Is there code that causes the pushbutton to be inoperable after first pushed, and then operable after the code completes?
(2) Is the "Wait" code the best way to do this or even necessary?
Here's the code for reference:
Code:
CutterPort = DLookup("[CutterPort]", "tblCutterData", "[Cutter] = " & CutterNumber)
SerComm.CommPort = CutterPort
SerComm.Settings = "9600,N,8,1"
SerComm.InBufferCount = 0 ' clear ports
SerComm.OutBufferCount = 0
SerComm.InputLen = 1 ' set InputData to 1 character
If SerComm.PortOpen = False Then SerComm.PortOpen = True
SerComm.Output = "W0F63" + strQtyOrdered + Chr$(&HD): DTRWait
SerComm.Output = "W0F93" + strQtyCut + Chr$(&HD): DTRWait
SerComm.Output = "W1043" + Hex(Me![LengthCalc]) + Chr$(&HD): DTRWait
SerComm.Output = "W1002" + Hex(0) + Chr$(&HD): DTRWait
SerComm.Output = "W1022" + Hex(0) + Chr$(&HD): DTRWait
SerComm.Output = "W1092" + Hex(0) + Chr$(&HD): DTRWait
SerComm.Output = "W1072" + Hex(0) + Chr$(&HD): DTRWait
SerComm.Output = "W0ED2" + Hex(Me![BF]) + Chr$(&HD): DTRWait
SerComm.Output = "W0BE2" + Hex(Me![Y]) + Chr$(&HD): DTRWait
SerComm.Output = "W0F01" + Hex(Me![FSpd]) + Chr$(&HD): DTRWait
SerComm.Output = "W0F11" + Hex(Me![CSpd]) + Chr$(&HD): DTRWait
SerComm.Output = "W0F21" + Hex(Me![FCorr]) + Chr$(&HD): DTRWait
SerComm.Output = "W0F41" + Hex(2) + Chr$(&HD): DTRWait
SerComm.Output = "W0E01" + Hex(Me![MarkerMode]) + Chr$(&HD): DTRWait
SerComm.Output = "W1822" + Hex(Me![MarkDistance]) + Chr$(&HD): DTRWait
SerComm.Output = "W1841" + Hex(Me![RetentionTime]) + Chr$(&HD): DTRWait
SerComm.Output = "W1851" + Hex(Me![WaitTime]) + Chr$(&HD): DTRWait
SerComm.Output = "G0001" + Chr$(&HD): DTRWait
SerComm.PortOpen = False
Sub DTRWait()
waitcount = 0
Do
waitcount = waitcount + 1
Loop Until (waitcount = 10000)
End Sub
Thanks!