M
Microsoft
I have a for loops that goes from 1 to 256
I test the number and exception is thrown if there is an error.
How do I get the program to stop in the middle of the loop and go to the
next increment if an exception is thrown. I can only figure out how to exit
the loop.
'read the text file
line = sr.ReadLine()
Do While Not line Is Nothing
subnet = line.Remove(line.Length - 1, 1)
For ip = 1 To 256
computer = subnet & ip
' Connect to IP and send results
Dim scope As New ManagementScope("\\" & computer & "\root\cimv2")
Dim objectQuery As New ObjectQuery("select * from Win32_OperatingSystem")
Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
Dim os As ManagementObject
Try
scope.Connect()
Catch ex As Exception
WOULD LIKE TO EXIT LOOP HERE AND GO ON TO NEXT NUMBER
End Try
For Each os In searcher.Get()
osname = os("caption")
dirname = os("windowsdirectory")
servername = os("name")
End If
Next os
I test the number and exception is thrown if there is an error.
How do I get the program to stop in the middle of the loop and go to the
next increment if an exception is thrown. I can only figure out how to exit
the loop.
'read the text file
line = sr.ReadLine()
Do While Not line Is Nothing
subnet = line.Remove(line.Length - 1, 1)
For ip = 1 To 256
computer = subnet & ip
' Connect to IP and send results
Dim scope As New ManagementScope("\\" & computer & "\root\cimv2")
Dim objectQuery As New ObjectQuery("select * from Win32_OperatingSystem")
Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
Dim os As ManagementObject
Try
scope.Connect()
Catch ex As Exception
WOULD LIKE TO EXIT LOOP HERE AND GO ON TO NEXT NUMBER
End Try
For Each os In searcher.Get()
osname = os("caption")
dirname = os("windowsdirectory")
servername = os("name")
End If
Next os