我要做一个发送和接受简单程序 我软件发送时我用导线把发送和接受端短接应该是发送什么在文本里面应该显示什么可是什么也没有请大家看看是什么原因呀! Private Sub Command2_Click() Text1.Text = buf End Sub
Private Sub Form_Load() Dim instring As String MSComm1.InputMode = comInputModeText MSComm1.InBufferSize = 1024 MSComm1.CommPort = 1 If Not MSComm1.PortOpen Then MSComm1.PortOpen = True End If MSComm1.Settings = "2400,N,8,1" MSComm1.InputLen = 0 MSComm1.InBufferCount = 0 MSComm1.RThreshold = 8 End Sub Private Sub Command1_Click() Dim buf1 As Variant Dim Data1(8) As Byte If Not MSComm1.PortOpen Then MSComm1.PortOpen = True End If Data1(0) = &H0 Data1(1) = &H11 Data1(2) = &H22 Data1(3) = &H33 Data1(4) = &H44 Data1(5) = &H55 Data1(6) = &H66 Data1(7) = &HAA buf1 = Data1 MSComm1.Output = buf1 MSComm1.PortOpen = False End Sub
Private Sub MSComm1_OnComm() If Not MSComm1.PortOpen Then MSComm1.PortOpen = True End If Select Case MSComm1.CommEvent Case comEvReceive buf = MSComm1.Input End Select MSComm1.PortOpen = False
End Sub |