Home > Software engineering >  About VB, mscomm control and Siemens PLC to traffic problems
About VB, mscomm control and Siemens PLC to traffic problems

Time:10-08

Private Sub MSComm1_OnComm ()
If Command2. Caption="stop accepting" Then
The Select Case CommEvent
Case comEvReceive
Temp=MSComm1. Input
ReDim Preserve temp (UBound (temp)) As Byte
For I=LBound (temp) To UBound (temp)
Text2=Text2 & amp; STR $(temp) (I) & amp; "
"Next I
End the Select

End the If

End Sub

Usb/ppi cable signal and received signal lights up, but did not show to the text2, there is something wrong with the code or any other reason, I hope you help, don't appreciate ~

CodePudding user response:

First you have to know what temp did receive data

CodePudding user response:

 If Command2. Caption="stop receiving Then 'check here first," string is the same as the command button shows the 
The Select Case CommEvent
Case comEvReceive
Temp=MSComm1. Input
If MSComm1. An InputMode=comInputModeText Then
Text2=StrConv (temp, vbUnicode)
The Else
For I=LBound (temp) To UBound (temp)
Text2=Text2 & amp; The IIf (Text2=""," ", "") & amp; Right (" 0 "& amp; Hex (temp (I)), 2)
Next I
End the If
End the Select
End the If
  • Related