Home > Software engineering >  VB serial port communication problem ~
VB serial port communication problem ~

Time:12-22

The great god, how so can't read serial data, [can read data in a serial debugging tools, although vb there no error, but can't read data]

CodePudding user response:

Should be no problem? Why is this

CodePudding user response:

Dim Buffer () As Byte
Buffer=MSComm1. Input

CodePudding user response:

refer to the original poster qq_30127511 response:
great god, how so can't read serial data, [can read data in a serial debugging tools, although vb there no error, but can't read data]

1. Receive wrong with variable, should such as bakw answer,
2. Did not see the MsComm control an InputMode attribute set, an InputMode attribute to determine how to retrieve the Input attribute data, the format of the data to retrieve or string or array of a data set of binary data, receiving byte array need to be set to comInputModeBinary,
3. Receive OnComm event trigger MsComm control, still need to set RThreshold properties is not equal to 0, the default value is 0, the attribute

CodePudding user response:

refer to the original poster qq_30127511 response:
great god, how so can't read serial data, [can read data in a serial debugging tools, although vb there no error, but can't read data]

Two problems, 1, is your Buffre variable module-level variables, if not we won't be able to pass Label1 control; 2, Label1 Caption attribute must have controls,

CodePudding user response:

 Dim Buffer () As Byte 

Private Sub MSComm1_OnComm ()
Buffer=MSComm1. Input
End Sub

Private Sub cmdReceive_Click ()
Libel1=StrConv (Buffer, vbUnicode)
End Sub

  • Related