PDA

Click to See Complete Forum and Search --> : catch formatexception error


Borry
Jun 19th, 2002, 03:10 AM
Hello everybody,


I want to know how I can catch a formatexception. Cause for some computers in this code (which are not on the network), I receive a system.formatexception. I've been trying to catch this exception but it always returns :(

Has anyone any clue about this ?

Thanks in advance,

Bjorn


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim strComputers(50, 1) As String
Dim i As Byte

strComputers(0, 0) = "BEQDENDEN1WS037"
strComputers(0, 1) = "beq03029"
strComputers(1, 0) = "beqdenden1ws042"
strComputers(1, 1) = "beq03039"
strComputers(2, 0) = "BEQDENDEN1WS047"
strComputers(2, 1) = "beq03031"
strComputers(3, 0) = "BEQDENDEN1WS048"
strComputers(3, 1) = "beq02971"
strComputers(4, 0) = "BEQDENDEN1WS052"
strComputers(4, 1) = "beq02973"
strComputers(5, 0) = "BEQDENDEN1WS056"
strComputers(5, 1) = "beq02965"
strComputers(6, 0) = "BEQDENDEN1WS061"
strComputers(6, 1) = "beq03014"

' MsgBox(strComputers.Length)


For i = 0 To strComputers.GetUpperBound(0)

If strComputers(i, 0) <> "" Then
Try ' Set up structured error handling.

Dim strHostName As IPHostEntry = Dns.GetHostByName(strComputers(i, 0))
MsgBox(strHostName.HostName())

MsgBox(strComputers(i, 0) & " : " & strComputers(i, 1))
Shell("net use z: \\" & strComputers(i, 0) & "\c$", AppWinStyle.MaximizedFocus, True)
If Directory.Exists("z:\") Then
If Directory.Exists("e:\users\" & strComputers(i, 1) & "\Application_Data") Then
Directory.Delete("e:\users\" & strComputers(i, 1) & "\Application_Data", True)
End If
Shell("xcopy z:\application_data e:\users\" & strComputers(i, 1) & "\Application_Data /s /e /C /I /Y", AppWinStyle.NormalFocus, True)
Shell("net use z: /d", , True)
End If

Catch ex As System.FormatException
MsgBox(strComputers(i, 0) & " not online !")
'Catch exc As System.FormatException ' Catch the error.
' MsgBox(strComputers(i, 0) & " not online !") ' Show friendly error message.
'Catch ex As Exception
' MsgBox(strComputers(i, 0) & " not online !") ' Show friendly error message.
End Try
End If
Next

MsgBox("the end")

End Sub