作者vanilla00520 (科你老母)
看板Visual_Basic
标题[VB6 ] MScomm资料传收
时间Sat Feb 23 20:14:58 2008
之前有请教过大大板上大大,但一直无法顺利传送,
我只是想藉由MSCOMM物件让A电脑传讯息给B电脑,
以下是我的程式码
(1) 传送端
private sub formsend_load()
if(mscomm1.portopen=true) then mscomm1.portopen=false
mscomm1.commport=1
mscomm1.settings="9600,n,8,1"
mscomm1.inputLen= 0
if(mscomm1.portopen=false) then mscomm1.portopen=true
text1=""
end sub
private sub cmdstar_click()
mscomm1.output=text1.text
text1.text="传送成功"
end sub
private sub cmdend_click()
if(mscomm1.portopen=true) then mscomm1.portopen=false
end
end sub
(2) 接收端
option explicit
dim baffer$
private sub cmdreceive_click()
mscomm1.commport=1
mscomm1.settings="9600,n,8,1"
mscomm1.inputLen= 0
if(mscomm1.portopen=false) then mscomm1.portopen=true
timer1.enabled=true
end sub
private sub timer1_timer()
buffer=buffer+mscomm1.input
text1.text=text1.text+buffer
end sub
private sub formreceive_load()
buffer=""
text1.text=""
timer1.interval=10
end sub
private sub cmdend_click()
if(mscomm1.portopen=true) then mscomm1.portopen=false
end
我两边commport是设1,用RS232母-母接头把电脑给接起来,
弄了很久一直无法顺利接收讯息,请大大给我一点指点,
大恩不言谢<(_ _)>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.127.112.148
1F:推 fysky:你的RxD与TxD有跳线吗? 02/24 00:38
2F:→ vanilla00520:请问大大指的是?...我只用双边都母头串起来 02/24 09:50
3F:→ vanilla00520:一楼大大谢谢搂~可以传输了^^ 02/24 16:02