我用扩展的com3,com4调试,双方都拿专用的工具的话能收发,如果一端用自己编的的话就不灵了,多谢。
Private Sub Command1_Click()
Dim Instring As String
Dim ytemp() As Byte
Dim stemp As String
stemp = Text1.Text
ytemp = StrConv(stemp, vbFromUnicode)
MSComm1.PortOpen = True
MSComm1.Output = ytemp
MSComm1.PortOpen = False
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 3
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeBinary
End Sub
Private Sub MSComm1_OnComm()
Dim ytemp() As Byte
Dim stemp As String
Select Case MSComm1.CommEvent
' Handle each event or error by placing
' code below each case statement
' Errors
Case comEventBreak ' A Break was received.
Case comEventFrame ' Framing Error
Case comEventOverrun ' Data Lost.
Case comEventRxOver ' Receive buffer overflow.
Case comEventRxParity ' Parity Error.
Case comEventTxFull ' Transmit buffer full.
Case comEventDCB ' Unexpected error retrieving DCB]
' Events
Case comEvCD ' Change in the CD line.
Case comEvCTS ' Change in the CTS line.
Case comEvDSR ' Change in the DSR line.
Case comEvRing ' Change in the Ring Indicator.
Case comEvReceive ' Received RThreshold # of
' chars.
ytemp = MSComm1.Input
stemp = StrConv(ytemp, vbUnicode)
Text2.Text = stemp
Case comEvSend ' There are SThreshold number of
' characters in the transmit
' buffer.
Case comEvEOF ' An EOF charater was found in
' the input stream
End Select
End Sub
Private Sub Command1_Click()
Dim Instring As String
Dim ytemp() As Byte
Dim stemp As String
stemp = Text1.Text
ytemp = StrConv(stemp, vbFromUnicode)
MSComm1.PortOpen = True
MSComm1.Output = ytemp
MSComm1.PortOpen = False
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 3
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeBinary
End Sub
Private Sub MSComm1_OnComm()
Dim ytemp() As Byte
Dim stemp As String
Select Case MSComm1.CommEvent
' Handle each event or error by placing
' code below each case statement
' Errors
Case comEventBreak ' A Break was received.
Case comEventFrame ' Framing Error
Case comEventOverrun ' Data Lost.
Case comEventRxOver ' Receive buffer overflow.
Case comEventRxParity ' Parity Error.
Case comEventTxFull ' Transmit buffer full.
Case comEventDCB ' Unexpected error retrieving DCB]
' Events
Case comEvCD ' Change in the CD line.
Case comEvCTS ' Change in the CTS line.
Case comEvDSR ' Change in the DSR line.
Case comEvRing ' Change in the Ring Indicator.
Case comEvReceive ' Received RThreshold # of
' chars.
ytemp = MSComm1.Input
stemp = StrConv(ytemp, vbUnicode)
Text2.Text = stemp
Case comEvSend ' There are SThreshold number of
' characters in the transmit
' buffer.
Case comEvEOF ' An EOF charater was found in
' the input stream
End Select
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货