[CODE]Dim portnum As Long
Dim start As String
Sub scanningports()
Dim porttwo As Long
portnum = Text1.Text
porttwo = Text2.Text
Command2.Enabled = True
On Error GoTo viriio
Do
portnum = portnum + 1
DoEvents
If start = True Then
'关闭当前WINSOCK
Winsock1.Close
'防止系统冻结
DoEvents
Winsock1.LocalPort = portnum
DoEvents
Text3.Text = portnum
Winsock1.Listen
DoEvents
Else
portnum = 0
Command1.Enabled = True
Text1.Locked = False
Text2.Locked = False
Exit Sub
End If
Winsock1.Close
DoEvents
Loop Until portnum >= porttwo
portnum = 0
Command1.Enabled = True
logport.Text = logport.Text & vbCrLf & "Scanning Ports Done!" & vbCrLf
Text1.Locked = False
Text2.Locked = False
viriio:
If Err.Number = 10048 Then
logport.Text = logport.Text & vbCrLf & "端口" & Winsock1.LocalPort & " 开启中"
Resume Next
End If
End Sub
Private Sub Command1_Click()
Command2.Enabled = True
If Text1.Text = "" Then
MsgBox "你必须指定开始端口号!"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "你必须指定一个结束端口号"
Exit Sub
End If
Text1.Locked = True
Text2.Locked = True
Command1.Enabled = False
Winsock1.Close
start = True
Call scanningports
logport.Text = logport.Text & vbCrLf & "端口" & Text1.Text & "- " & Text3.Text & " 已经成功扫描!"
End Sub
Private Sub Command2_Click()
Command2.Enabled = False
start = False
End Sub[/CODE]
哪里转来的?