Dim? uout? As? different
uout? =? “& amph "? & amp? Hexadecimal (Val(Text 1. Text)) Here uout is actually a string, which is a hexadecimal string of 16.
Note that I said the hexadecimal string of 16, not the hexadecimal number of 16.
MSComm 1。 Output? =? Chr(uout) So what is sent here? Chr has a string. Actually, the parameter of Chr should be long.
Actually, this is how I understand what you mean.
Get the value in the text box (Text 1. Text), not more than one byte expression range (greater than 0 and less than 256).
Send this value via MSComm 1
If this idea is correct, you can refer to the following code.
? With code? Buffer? There is only one length.
? Because this code is only used to send one byte at a time.
? Variable declaration
Dim? uOut? As? Double? Save the entered value.
Dim? Buffer (0)? As? Bytes? ? Buffering of communication output
? Get? Text 1。 Words? The value of
uOut? =? Val(Text 1。 Text)
? Range check of byte (unsigned 1 byte) type data
What if? uOut? & gt? & ampHFF? then what uOut? =? & ampHFF
What if? uOut? & lt? & ampH00? then what uOut? =? & ampH00
? Output to VB in 16 format? Text 2
Text 2. Words? =? “& amph "? & amp? CInt (output)
? Write the value to be output to the buffer.
Buffer (0)? =? Val (text 2. Text)
? Write the value in the buffer to the terminal.
MSComm 1。 Output? =? If you send a byte instead of a byte, you need to send an&; A string starting with H.
Then refer to the following code:
? Variable declaration
Dim? uOut? As? Double? Save the entered value.
Dim? Buffer ()? As? Bytes? Buffering of communication output
? Get? Text 1。 Words? The value of
uOut? =? Val(Text 1。 Text)
? Output to VB in 16 format? Text 2
Text 2. Words? =? “& amph "? & amp? CInt (output)
? Writes the string to be output to the buffer.
Buffer? =? Text 2. text
? Write the value in the buffer to the terminal.
MSComm 1。 Output? =? buffer