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
    DoEvents
End 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
     DoEvents
End Sub
2个问题:
1、点击command3的“结束”,在timer5的任意空行处跳出循环,即执行isStarted = False ;
2、做一个时间条来显示mLoopTime,随着mLoopTime时间的减小,这个时间条逐渐变短,就跟游戏里显示还剩多少血一样,这个表示还剩多少时间。