在按钮的CLICKED事件下面写的发送代码如下:
string str
long cport=1
if rb_1.checked=true then cport=1
if rb_2.checked=true then cport=2
if rb_3.checked=true then cport=3
if rb_4.checked=true then cport=4
ole_1.object.commport=cport
ole_1.object.portopen=true
str=""
str=str+char(27)+char(91)+char(72)
str=str+sle_1.text+"~r~n"
str=str+char(27)+char(91)+char(66)
str=str+sle_2.text+"~r~n"
mle_1.text=str+"~r~n"
ole_1.object.output=str
ole_1.object.portopen=false
在另一按钮的CLICKED事件以及OLE的ONCOMM事件下面写的接收代码如下:
string str
long cport=1
if rb_1.checked=true then cport=1
if rb_2.checked=true then cport=2
if rb_3.checked=true then cport=3
if rb_4.checked=true then cport=4
ole_1.object.commport=cport
ole_1.object.portopen=true
str=ole_1.object.input
if str="" then
else
mle_2.text=str
messagebox("提示信息","能从串口接收数据!")
end if
ole_1.object.portopen=false
OLE控件除开RTHRESHOLD属性设为1外其他都采用默认设置,请高手指点谢谢!