可以将MSComm控件的InputMode 属性设置成comInputModeBinary 的二进制发送方式这样就可以发送了,但必须将82H放入一个字节型数组中,再发送此数组。
解决方案 »
- 有人用过leadtools13编程吗?如果判断图像的大小是A3还是A2幅面的?
- 帮帮忙了
- 有没有网口调试的控件就像MSCOMM那样的?
- 使用:Ado+DataGrid+access表,如何在查看时锁定列?
- 谁能给一段判断 完数 的算法?
- 请介绍一些较好的制作安装程序的工具
- ADO中同一个Connection打开的RecordSet个数有没有限制?
- 谁给我四个图标文件,我送他100分
- 求助!大于64KB的图像文件怎样存入到ORACLE数据库表中(用ADO连接库),高难问题!!!
- 跟大家说个事。控件数组不是数组,所以不能用操作数组的方法去操作控件“数组”。
- 如何实现把多个图象读到内存。
- VB还有这个错?
If MSComm.PortOpen = False Then
MSComm.CommPort = 1
MSComm.Settings = "9600,N,8,1"
frmMain.MSCommMain.PortOpen = False
MSComm.PortOpen = True
MSComm.InputMode = comInputModeBinary
End If
End Sub
Private Sub CmdSend_Click()
Dim OutputOrder(0) As Byte
OutputOrder(0) = &H82
MSComm.Output = OutputOrder '发请求
End Sub
如果要发送一串数据,可以将其放到一个大一点的数组中再发送。
Private Sub Form_Load()
If MSComm.PortOpen = False Then
MSComm.CommPort = 1
MSComm.Settings = "9600,N,8,1"
MSComm.PortOpen = True
MSComm.InputMode = comInputModeBinary
End If
End Sub
Private Sub CmdSend_Click()
Dim OutputOrder(0) As Byte
OutputOrder(0) = &H82
MSComm.Output = OutputOrder '发请求
End Sub
private sub cmdReceive_click()
dim buf as string
while len(buf)=0
buf = Mscomm.input
wEnd
End Sub
请问这个button收以上程序的发送,会收到什么呢?
将MSComm控件的RThreshold和SThreshold属性值设为1,
Private Sub MSComm_OnComm()
Select Case ......
...
Select Case MSComm.CommEvent
Case comEvReceive ' 收到 RThreshold 个单片机发来的字符
Dim buf() As Byte
buf = MSComm.InputEnd Select
End Select
End Sub
这样在buf里收到的将是82H.