Public Function CMD_rec_detectionRUenable() 'RU使能查询/设置解析
    Dim i As Integer
    Dim J As Integer
    Dim ocbyt(11) As Byte
   
    For i = 0 To 11
        ocbyt(i) = CRCdata(i + 6)
    Next
'    For i = 0 To 11
'        ocbyt(i) = BytReceived(i + 6)
'    Next
    
'没有用数组,因为界面与监控板不符
    With COMForm
'        .Label20.Caption = "PD Alarm"
'        .Label21.Caption = "LD Alarm"
'        .Label22.Caption = "VSWR"
'        .Label17.Visible = False
'        .Shape8(5).Visible = False
'        .EACheck1(5).Visible = False
'        .Label23.Move 120, 3720, 1695, 375
'        .Shape8(6).Move 1800, 3600, 375, 375
'        .EACheck1(6).Move 2640, 3720, 255, 255    If ocbyt(0) = 0 Then  'AC
        .Shape8(0).BorderColor = QBColor(8)
        .Shape8(0).FillColor = vbYellow
    Else
    If ocbyt(0) = 1 Then
        .Shape8(0).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(1) = 0 Then  'Door
        .Shape8(1).BorderColor = QBColor(8)
        .Shape8(1).FillColor = vbYellow
    Else
    If ocbyt(1) = 1 Then
        .Shape8(1).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(3) = 0 Then 'PD
        .Shape8(2).BorderColor = QBColor(8)
        .Shape8(2).FillColor = vbYellow
    Else
    If ocbyt(3) = 1 Then
        .Shape8(2).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(4) = 0 Then  'LD
        .Shape8(3).BorderColor = QBColor(8)
        .Shape8(3).FillColor = vbYellow
    Else
    If ocbyt(4) = 1 Then
        .Shape8(3).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(2) = 0 Then  'Over_temp
        .Shape8(6).BorderColor = QBColor(8)
        .Shape8(6).FillColor = vbYellow
    Else
    If ocbyt(2) = 1 Then
        .Shape8(6).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(8) = 0 Then 'CDMA_PA_Low
        .Shape8(7).BorderColor = QBColor(8)
        .Shape8(7).FillColor = vbYellow
    Else
    If ocbyt(8) = 1 Then
        .Shape8(7).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(7) = 0 Then 'CDMA_PA_High
        .Shape8(8).BorderColor = QBColor(8)
        .Shape8(8).FillColor = vbYellow
    Else
    If ocbyt(7) = 1 Then
        .Shape8(8).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(10) = 0 Then 'PSC_PA_Low
        .Shape8(9).BorderColor = QBColor(8)
        .Shape8(9).FillColor = vbYellow
    Else
    If ocbyt(10) = 1 Then
        .Shape8(9).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(9) = 0 Then 'PSC_PA_High
        .Shape8(10).BorderColor = QBColor(8)
        .Shape8(10).FillColor = vbYellow
    Else
    If ocbyt(9) = 1 Then
        .Shape8(10).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(11) = 0 Then  'VSWR
        .Shape8(11).BorderColor = QBColor(8)
        .Shape8(11).FillColor = vbYellow
    Else
    If ocbyt(11) = 1 Then
        .Shape8(11).BorderColor = vbGreen
    End If
    End If
   ' .Timer3.Enabled = False
   '.whileTimer.Enabled = False
    End With
    sendFlag = 3
    funWhile
End Function
Public Function CMD_rec_detectionMUenable() 'MU使能查询/设置解析
    Dim i As Integer
    Dim J As Integer
    Dim ocbyt(11)
   ' MsgBox "CMD_rec_detectionRUenable ok"
    For i = 0 To 10
        ocbyt(i) = CRCdata(i + 6)
    Next
    
'    For j = 0 To 10
'    If ocbyt(j) = 0 Then
'        Shape8(j).FillColor = QBColor(8)
'    Else
'    If ocbyt(j) = 1 Then
'        Shape8(j).FillColor = vbGreen
'    End If
'    End If
'    Next j
'没有用数组,因为界面与监控板不符
    With COMForm
    If ocbyt(0) = 0 Then  'AC
        .Shape8(0).BorderColor = QBColor(8)
    Else
    If ocbyt(0) = 1 Then
        .Shape8(0).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(1) = 0 Then  'Door
        .Shape8(1).BorderColor = QBColor(8)
    Else
    If ocbyt(1) = 1 Then
        .Shape8(1).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(3) = 0 Then 'PD1
        .Shape8(2).BorderColor = QBColor(8)
    Else
    If ocbyt(3) = 1 Then
        .Shape8(2).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(4) = 0 Then  'LD1
        .Shape8(3).BorderColor = QBColor(8)
    Else
    If ocbyt(4) = 1 Then
        .Shape8(3).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(5) = 0 Then 'PD2
        .Shape8(4).BorderColor = QBColor(8)
    Else
    If ocbyt(5) = 1 Then
        .Shape8(4).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(6) = 0 Then  'LD2
        .Shape8(5).BorderColor = QBColor(8)
    Else
    If ocbyt(6) = 1 Then
        .Shape8(5).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(2) = 0 Then  'Over_temp
        .Shape8(6).BorderColor = QBColor(8)
    Else
    If ocbyt(2) = 1 Then
        .Shape8(6).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(8) = 0 Then 'CDMA_PA_Low
        .Shape8(7).BorderColor = QBColor(8)
    Else
    If ocbyt(8) = 1 Then
        .Shape8(7).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(7) = 0 Then 'CDMA_PA_High
        .Shape8(8).BorderColor = QBColor(8)
    Else
    If ocbyt(7) = 1 Then
        .Shape8(8).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(10) = 0 Then 'PSC_PA_Low
        .Shape8(9).BorderColor = QBColor(8)
    Else
    If ocbyt(10) = 1 Then
        .Shape8(9).BorderColor = vbGreen
    End If
    End If
    
    If ocbyt(9) = 0 Then 'PSC_PA_High
        .Shape8(10).BorderColor = QBColor(8)
    Else
    If ocbyt(9) = 1 Then
        .Shape8(10).BorderColor = vbGreen
    End If
    End If
    
    End With
End FunctionPublic Function CMD_rec_detectionRUThreshold() 'RU告警门限查询解析
    Dim i As Integer
    Dim J As Integer
    Dim ocbyt(4)
   ' MsgBox "CMD_rec_detectionRUThreshold ok"
   
    For i = 0 To 4
        ocbyt(i) = CRCdata(i + 6)
    Next
    
'    For i = 0 To 4
'        ocbyt(i) = BytReceived(i + 6)
'    Next
'
'没有用数组,因为界面与监控板不符
    With COMForm
'         .Label20.Caption = "PD Alarm"
'        .Label21.Caption = "LD Alarm"
'        .Label22.Caption = "VSWR"
'        .Label17.Visible = False
'        .Shape8(5).Visible = False
'        .EACheck1(5).Visible = False
'         .Label23.Move 120, 3720, 1695, 375
'        .Shape8(6).Move 1800, 3600, 375, 375
'        .EACheck1(6).Move 2640, 3720, 255, 255
        .Combo6.Text = ocbyt(0)
        .Combo8.Text = ocbyt(1)
        .CDMA_Output_Under_Power_ThresholdCmb.Text = ocbyt(2)
        .Combo11.Text = ocbyt(3)
        .Combo10.Text = ocbyt(4)
      '  .Timer5.Enabled = False
     ' .whileTimer.Enabled = False
    End With
    sendFlag = 5
    funWhile
End Function

解决方案 »

  1.   

    下班了,你这个貌似只执行了一次吧,没细看,你可以尝试下面的方法:
    Private Sub Command11_Click()
        Select Case Command11.Caption
        Case "Read"
            whileFlag = True
            Command11.Caption = "Stop"
            Timer1.Enabled = True ''启动定时器
        Case "Stop"
            whileFlag = False
            Command11.Caption = "Read"
        End Select
    End Sub
    Private Sub Timer1_Timer()
        Timer1.Enabled = False
        If Not whileFlag Then Exit Sub ''如果停止则直接退出
        SendSomeThings ''执行发送过程
        Timer1.Enabled = True ''恢复定时器
    End Sub
    你参考着看看...
      

  2.   

    程序太长看不了
    只是很奇怪,明明有中断事件为何还要用轮询?还有, 你可以直接解释执行, 等到停止循环的时候按"ctrl"+"break"键看看停在哪里
      

  3.   

    在本机安装VB6开发环境,将源代码也放到本机,在VB6 IDE里面运行。
    当停止循环时,在VB6 IDE中按Ctrl+Break键,看程序停在源代码哪里。
      

  4.   

    轮询用Timer控件实现,接收用MsComm控件的OnComm事件实现。