|
-
May 4th, 2001, 10:57 PM
#1
Thread Starter
Junior Member
ping loop
I'm trying to get this program to ping a range of ip address. i got it so that it can ping the starting ip address but cannot have it loop so that it will ping all the ip address in between the range.. example...
ping 192.168.1.1 to 192.168.1.20
and write the ip status in a log file.
so far it can ping one ip address, but when i put the code in a loop it doenst ping at all. i double checked the loop code, the loop works. but once i add it to the other code, it stops pinging, the program does not through up anyerrors at or.
heres the code that i have...
it will increment the last octect in the ip address.
example(192.168.1.1 last octet is 1.)
------------------------------------------------------------------
once i add the loop it doesnt work, i get rid of just the loop code and it works. everthing between the DIM INTLOOP and the LOOP text is the code that pings.
-------------------------------------------------------------------
Dim intLoop As Integer
For intLoop = Val(txtText(0).Text) To Val(txtText(7).Text)
Dim ECHO As ICMP_ECHO_REPLY
Dim pos As Long
Dim success As Long
If SocketsInitialize() Then
'ping the ip passing the address, text to send, and the ECHO structure.
success = Ping((txtText(0).Text) & "." & (txtText(1).Text) & "." & (txtText(2).Text) & "." & (txtText(3).Text), (txtText(0).Text), ECHO)
'display the results
Dim b As String
Dim c As String
b = GetStatusCode(success)
c = ECHO.RoundTripTime & " ms"
SocketsCleanup
Else
MsgBox "Winsocks for 32-bit Windows environment is not responding."
End If
With ListView1.ListItems
.Add , , (txtText(0).Text) & "." & (txtText(1).Text) & "." & (txtText(2).Text) & "." & (txtText(3).Text)
End With
'adds to the second column, 1rst row
ListView1.ListItems(1).SubItems(1) = b
' adds to the fourth column, 1rst row
ListView1.ListItems(1).SubItems(2) = c
frmIPLog.List1.AddItem (txtText(0).Text) & "." & (txtText(1).Text & "." & txtText(2).Text & "." & txtText(3).Text) & vbTab & b & vbTab & vbTab & c
Next intLoop
if anyone can help me, it would be MUCH appreciated. i just cant figure it out. thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|