Try and catch Exception: InvalidCastException
Imports System
Imports System.Diagnostics
Public Class MainClass
Shared Sub Main()
Try
Dim i As Integer = CInt("bad value")
Catch ex As InvalidCastException
Dim txt As String = "InvalidCastException"
MsgBox(txt)
Catch ex As Exception
Dim txt As String = "Exception"
MsgBox(txt)
End Try
End Sub
End Class
Related examples in the same category