求:VB串口通信不使用API和 MSComm控件
求:VB串口通信不使用API和 MSComm控件的方法。
[解决办法]
VB6调试通过,采用Open文件方式实行串口异步通信,注意:
1)波特率在1200及以下没大问题
2)只能发送或接收0-127之间的ASCII码
Private Sub Command1_Click()
Dim sj(3) As Byte
sj(0) = 50
sj(1) = 49
sj(2) = 48
sj(3) = 0
Open "COM1:1200,N,7,1" For Random As #1
Put #1, , sj
Close #1
End Sub
Private Sub Command2_Click()
Dim strsj As String '文本发送
strsj = "123abcd"
Open "COM1:1200,N,7,1" For Output As #1
Print #1, strsj
Close #1
End Sub