![](http://www.atcpu.com/themes/extres/ithread/images/2.gif) | Private Sub Command1_Click() Dim x As Integer Dim items As ListItem Dim PortsChecked As Integer PortsChecked = Int(Text1.Text) '逐个端口检测 For x = 1 To PortsChecked Label2.Caption = "扫描中。。。" DoEvents Winsock1.LocalPort = x On Error Resume Next Winsock1.Listen '如果得到错误代码,说明此端口被使用 If Err.Number = 10048 Then Set items = ListView1.ListItems.Add(, , Winsock1.LocalIP) items.SubItems(1) = x Err.Number = 0 End If Winsock1.Close Label2.Caption = "扫描完毕。。。" Next x End Sub
| |