WinSock1.SendData cmd2
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public Sub wait1000()
Dim StartNum As Long
Dim EndNum As Long
StartNum = GetTickCount
DoEvents
LL: EndNum = GetTickCount
DoEvents
If EndNum - StartNum >= 1000 Then
Exit Sub
Else
GoTo LL
End If
'加一个Timer 控件,设定Timer1.Interval = 1000
'代码如下:
Dim cmd(1) As String
Private Sub Timer1_Timer()
Static i As Integer
sendD i
i = i + 1
If i > 2 Then Timer1.Enabled = False: i = 0
End Sub
Private Sub sendD(i As Integer)
WinSock1.SendData cmd(i)
End Sub
Private Sub Command1_Click()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub