你可以這樣;
連結前設定一個變量nTimeOut=30,用timer每一秒檢查一下nTimeOut是否小於0,如不是就-1,
如果是,則關閉連線 nTimeOut=30
Private sub Timer1_Timer()
if nTimeOut<0 then
if sckClient.State<>7 then sckClient.close
Timer1.Enabled=false
else
nTimeOut=nTimeOut-1
end if
end sub
連結前設定一個變量nTimeOut=30,用timer每一秒檢查一下nTimeOut是否小於0,如不是就-1,
如果是,則關閉連線 nTimeOut=30
Private sub Timer1_Timer()
if nTimeOut<0 then
if sckClient.State<>7 then sckClient.close
Timer1.Enabled=false
else
nTimeOut=nTimeOut-1
end if
end sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货