我寫了一支程式用來和rs232的printer溝通,傳送時沒有什麼問題,可
是接收時卻沒有反應,不知為什麼??我的程式接收的部份如下:
Private Sub MSComm1_OnComm()
Dim rb() As Byte
    Dim buf As String
    Select Case MSComm1.CommEvent

Case 8006
          MsgBox "設備不存在或無法辨識!", vbExclamation, "警告!"

Case 8007
          MsgBox "設備不支援此速率!", vbExclamation, "警告!"

Case 8010
          MsgBox "設備無法獲得或已被占用!", vbExclamation, "警告!"

Case 8012
          MsgBox "設備未開機!", vbExclamation, "警告!"

Case 8020
          MsgBox "RS232信號中斷!", vbExclamation, "警告!"

Case 8021
          MsgBox "RS232信號中斷!", vbExclamation, "警告!"

Case 1001
          MsgBox "RS232信號中斷!", vbExclamation, "警告!"

Case comEvReceive
          
           rb = MSComm1.Input
           For i = LBound(rb) To UBound(rb)
             buf = buf + CStr(rb(i))
           Next
          
           MsgBox buf, vbCritical, "com input"
          
    End Select
    
End Sub
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(1) 人氣()