作者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
推 fysky:你的RxD與TxD有跳線嗎? 02/24 00:38
→ vanilla00520:請問大大指的是?...我只用雙邊都母頭串起來 02/24 09:50
→ vanilla00520:一樓大大謝謝摟~可以傳輸了^^ 02/24 16:02