hi all coders
this is port scanner program, i've written.but there is error which i ca not solve it please help me soon.
Option Explicit
Dim cancel As Boolean
Private Sub CmndScan_Click()
Dim PortNumber As Long
On Error Resume Next
If (TxtFrom.Text <= TxtTo.Text) And Len(Trim(TxtIP.Text)) <> 0 Then
TxtFrom.Locked = True: TxtTo.Locked = True: TxtIP.Locked = True
CmndScan.Enabled = False: CmndStop.Enabled = True
PortNumber = CLng(TxtFrom.Text)
Do
DoEvents
Winsock1.Connect TxtIP.Text, TxtTo.Text
Winsock1.LocalPort = PortNumber 'invalid operation in current state
Winsock1.Listen
If Err.Number > 0 Then
LstResult.AddItem "Error : " & Err.Description
Else
LstResult.AddItem "Port" & PortNumber & " is available "
End If
DoEvents
PortNumber = PortNumber + 1
If cancel = True Then Exit Do
Loop Until (PortNumber >= TxtTo.Text)
End If
cancel = False
TxtFrom.Locked = False: TxtTo.Locked = False: TxtIP.Locked = False
Winsock1.Close
End Sub
Private Sub CmndStop_Click()
CmndScan.Enabled = True: CmndStop.Enabled = False
Winsock1.Close
LstResult.Clear
cancel = True
End Sub
Private Sub Form_Load()
cancel = False
End Sub
____________________________
Persia
26-08-2003 at 04:53 PM
|
JLRodgers Level: Moderator Registered: 04-04-2002 Posts: 1617
Re: Port Scanner
While I'm probably not going to go in depth with any responses to this...
You never said why or what the error is, not to mention some ports can't be connected to without causing problems anyway.
____________________________ Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)