Home > Software engineering > VB and PLC communication applications, problems: to accept the information can't echo to text2,
VB and PLC communication applications, problems: to accept the information can't echo to text2,
Time:10-09
Private Sub MSComm1_OnComm ()
Dim temp () As Byte Dim RCV () As Byte Dim rcvlenth As Integer Rcvlenth=1
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) Rcvlenth=rcvlenth + 1 RCV (I)=temp (I) Next I
ReDim Preserve RCV (rcvlenth) As Byte For I=LBound (RCV) To UBound (RCV) Text2=Text2 & amp; STR $(RCV) (I) & amp; " "Next I End the Select End the If
Code as above, please help to look at thank you ~ ~
CodePudding user response:
Temp=MSComm1. Input ReDim Preserve temp (UBound (temp)) As Byte
Suppose you first sentence has been accepted to the data, the second sentence redefine what length for? Besides, it with the as redim Byte, it can only change the length, can't change the type of the (even before and the definition of the same type)