VB给单片机发数据问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 10:47:30
用VB的MSCOMM给单片机发十六进制的数11,单片机收到后把11送过来,用VB的text显示,请问高手怎么编写VB的程序,谢谢!
是一秒钟发送一个数据11

Option Explicit
Dim intTime As Integer
Private strSendText As String '发送文本数据
Private bytSendByte() As Byte '发送二进制数据
Private blnReceiveFlag As Boolean
Private blnAutoSendFlag As Boolean
Private intPort As Integer
Private strSet As String
Private intReceiveLen As Integer
Private bytReceiveByte() As Byte
Private strAscii As String '设置初值
Private strHex As String
Private intHexWidth As Integer
Private intLine As Integer
Private m As Integer
Private strAddress As String
'字符表示的十六进制数转化为相应的整数,错误则返回 -1
Function ConvertHexChr(str As String) As Integer
Dim test As Integer
test = Asc(str)
If test >= Asc("0") And test <= Asc("9") Then
test = test - Asc("0")
ElseIf test >= Asc("a") And test <= Asc("f") Then
test = test - Asc("a") + 10
ElseIf