Parse Number Exception
Imports System Public Class MainClass Shared Sub Main(ByVal args As String()) Dim num_items As Integer Try num_items = Integer.Parse("aa") Catch ex As Exception Console.WriteLine("Error in Num Items." & vbCrLf & ex.Message) Exit Sub End Try ' Check that the value is between 1 and 100. If num_items < 1 Or num_items > 100 Then Console.WriteLine("Num Items must be between 1 and 100") Exit Sub End If End Sub End Class
1. | Use Argument Exception | ||
2. | ArgumentException Class | ||
3. | OverflowException Class |