VB6写的一个端口批量扫描器

Private Sub cmdStart_Click() Dim i As Long Dim j As Integer Dim k As Long, l As Long Dim t As String, ts As String, tip As String ts = txtList1.Text t = " " j = Int(txtPort.Text) If j < 1 Or j > 65535 Then MsgBox "检查端口号之于0-65535之间", vbExclamation, "端口错误" End If ' Dim c As Long txtList2.Text = "" cmdStart.Enabled = False cmdStop.Enabled = True k = 0 l = 0 Do Until t = "" k = k 1 If st = True Then cmdStart.Enabled = True st = False Exit Do End If t = GetStr(ts, "", vbCrLf, i) c = 0 If Len(t) >= 4 Then '如果不是空的 tip = GetStr(t, "", txtsp.Text) 'tip = GetStr(tip, vbCrLf, "") tip = Replace(tip, Chr(10), "") tip = Replace(tip, Chr(13), "") If Client1.State <> sckClosed Then Client1.Close ' MsgBox Client1.State & vbCrLf & tip & ":" & j Client1.RemoteHost = tip Client1.RemotePort = j Client1.Connect tip, j Do Until Client1.State = 7 DoEvents PauseTime 10 c = c 1 If c > 10 Then GoTo a End If Loop If Client1.State = sckConnected Then l = l 1 If txtList2.Text = "" Then txtList2.Text = tip Else: txtList2.Text = txtList2.Text & vbCrLf & tip End Ifa: Client1.Close End If End If Lbl1.Caption = "已扫:" & k - 1 & "条 | 连接上:" & l & "条" Loop MsgBox "扫描结束", vbInformation cmdStart.Enabled = True cmdStop.Enabled = FalseEnd Sub