小弟最近刚学VB,我用MSComm控件获取电子称上的数据,我在以前软件的基础上更改了下获取公式,但是现在问题是刚用的时候,很快就能获取到数据,现在要2分钟左右才行,还有越来越慢的趋势,请高手给指导下,代码是:
Private Sub MSComm1_OnComm()
Dim llc As Variant
Dim a(6) As Long
On Error GoTo errmsgSelect Case MSComm1.CommEvent
   Case comEvReceive
       llc = MSComm1.Input
       lld = llc
  
      If lld(1) = 2 Then
         a(1) = (lld(1 + 2) - 48) * 100000
         a(2) = lld(1 + 3) - 48
         a(0) = a(2) * 10000
         a(3) = (lld(1 + 4) - 48) * 1000
         a(4) = (lld(1 + 5) - 48) * 100
         a(5) = lld(1 + 6) - 48
         a(5) = a(5) * 10
         a(6) = lld(1 + 7) - 48
         ss = a(1) + a(0) + a(3) + a(4) + a(5) + a(6)
      End If
   
    
    If Option1.Value = True Then
                   
       SQL = "select * from uwhssk where 原料='" & Combo1.Text & "' "
       Adodc2.CommandType = adCmdText
       Adodc2.RecordSource = SQL
       Adodc2.Refresh
       
       If Adodc2.Recordset.EOF = False Then
          xs = Adodc2.Recordset(2)
       Else
          xs = 0
       End If
         ss = Int(ss * xs)
              
    End If
    
    If ss >= 80000 Then
       ss = 80000
    End If    If ss = 0 Then
       Text12.Text = "重选品种"
    Else
       SQL = "select * from uwhssk where 原料='" & Combo1.Text & "' "
       Adodc2.CommandType = adCmdText
       Adodc2.RecordSource = SQL
       Adodc2.Refresh
       
       If Adodc2.Recordset.EOF = False Then
          If Text7.Text <> "" Then
             Text12.Text = ss
          Else
             Text12.Text = "输入车号"
          End If
       End If
     End If     If MSComm1.PortOpen = True Then
        MSComm1.PortOpen = False
     End If
    
End Select
   
Exit Sub
errmsg:
   MsgBox "非法操作"
End Sub 
时间控件:
Private Sub Timer1_Timer()
Dim lla As VariantIf MSComm1.PortOpen = True Then
   MSComm1.PortOpen = False
End IfMSComm1.CommPort = 1
MSComm1.Settings = "2400,n,8,1"
MSComm1.InputLen = 0
MSComm1.InBufferSize = 36
MSComm1.OutBufferSize = 36
MSComm1.InputMode = comInputModeBinary
MSComm1.SThreshold = 0
MSComm1.RTSEnable = FalseIf MSComm1.PortOpen = False Then
   MSComm1.PortOpen = True
End If
   Do
      DoEvents
   Loop Until MSComm1.OutBufferCount = 0
MSComm1.InBufferCount = 0
MSComm1.RThreshold = 36
MSComm1.RTSEnable = True
Label10.Caption = Date + TimeEnd Sub
我是不是还要加上清缓存的代码啊?