下面是在一个程序中写的实现此功能的程序段,你自己分析吧。 If Combo1(0) = "所有客户机" Then fsp = MsgBox("确实要免费开通所有的客户机吗?此项功能是专为学校等免费的机房设置的。", 1) If fsp = 1 Then For j = 0 To khjsm - 1 If newdatatxt(j).newmode <> "断开" Then If newdatatxt(j).newmode = "停止" Then newdatatxt(j).openmode = 1 newdatatxt(j).timexj = Val(Text1(1).Text) 'newdatatxt(j).opentime = Now() End If userid = j fsnr = fsdata fsnrok = False Timer1.Interval = 100 While Not fsnrok DoEvents Wend End If Next End If Private Sub Timer1_Timer() Timer1.Interval = 0 fsdatacom newdatatxt(userid).newname, fsnr fsnrok = True End SubPublic Sub fsdatacom(khjname As String, fsdata As String) On Error Resume Next Dim cbok As Boolean cbok = False For i = 0 To khjsm - 1 If newdatatxt(i).newname = khjname Then If newdatatxt(i).userip <> "" Then MDIForm1.tcpServer(0).RemoteHost = newdatatxt(i).userip MDIForm1.tcpServer(0).SendData fsdata cbok = True Else MsgBox ("目标客户机没法接通") End If End If Next If cbok = False Then MsgBox ("没有已接通的客户机") End Sub经验:如果不用时间控件来间隔数据的发送,会出现阻塞。
fsp = MsgBox("确实要免费开通所有的客户机吗?此项功能是专为学校等免费的机房设置的。", 1)
If fsp = 1 Then
For j = 0 To khjsm - 1
If newdatatxt(j).newmode <> "断开" Then
If newdatatxt(j).newmode = "停止" Then
newdatatxt(j).openmode = 1
newdatatxt(j).timexj = Val(Text1(1).Text)
'newdatatxt(j).opentime = Now()
End If
userid = j
fsnr = fsdata
fsnrok = False
Timer1.Interval = 100
While Not fsnrok
DoEvents
Wend End If
Next
End If
Private Sub Timer1_Timer()
Timer1.Interval = 0
fsdatacom newdatatxt(userid).newname, fsnr
fsnrok = True
End SubPublic Sub fsdatacom(khjname As String, fsdata As String)
On Error Resume Next
Dim cbok As Boolean
cbok = False
For i = 0 To khjsm - 1
If newdatatxt(i).newname = khjname Then
If newdatatxt(i).userip <> "" Then
MDIForm1.tcpServer(0).RemoteHost = newdatatxt(i).userip
MDIForm1.tcpServer(0).SendData fsdata
cbok = True
Else
MsgBox ("目标客户机没法接通")
End If
End If
Next
If cbok = False Then MsgBox ("没有已接通的客户机")
End Sub经验:如果不用时间控件来间隔数据的发送,会出现阻塞。