针对这段程序有2个问题
Private Sub Timer5_Timer() Timer5.Enabled = False Dim currentdate As Date Dim currentdate1 As Date Dim EnStatus As Integer Dim EnAlarm As Integer currentdate = Now currentdate1 = currentdate Do Do If Not isStarted Then Exit Do DoEvents Else Call DataSend(&HE6, MSComm1) DoEvents Call Sleep(tE6 * 1000) Call DataSend(&HFE, MSComm1) DoEvents Call Sleep(tFE * 1000) End If DoEvents Loop While Not DateDiff("s", currentdate, Now) > lLoopTime * 60 If Not isStarted Then Exit Do Else Call DataSend(&HD6, MSComm1) Call Sleep(tD6 * 1000) Call DataSend(&H76, MSComm1) Call Sleep(t76 * 1000) Call DataSend(&HB6, MSComm1) Call Sleep(tB6 * 1000) Call DataSend(&H76, MSComm1) Call Sleep(t76 * 1000) currentdate = Now End If DoEvents Loop While Not DateDiff("s", currentdate1, Now) > (mLoopTime - 0.5) * 60 isStarted = False Call EndSend DoEventsEnd SubPrivate Sub Command3_Click() If Shape3.BackColor = &HFF Then Shape3.BackColor = &H80FF80 Command3.Caption = "结束" '这个只是界面上显示“结束”字样,想结束,点击它。 MSComm1.Settings = "9600,N,8,1" ' 9600 波特,无奇偶校验,8 位数据,一个筛选结束位。 MSComm1.InputLen = 0 ' 当输入占用时,告诉控件读入整个缓冲区。 If MSComm1.PortOpen = False Then MSComm1.PortOpen = True End If isStarted = True isEnd = False Timer5.Enabled = True Else isStarted = False '点击“结束”执行此操作。 End If DoEventsEnd Sub