26 Program for student registration using Exception Handling in VB.net

Code :

Module Module1
    Dim name As String
    Dim rollno As Integer
    Dim per As Double
    Dim ch As Boolean
    Sub Form()
        Console.WriteLine("Fill Registration Form: ")
        Console.WriteLine("Enter name , rollno and percentage:")
        name = Console.ReadLine()
        rollno = Console.ReadLine()
        per = Console.ReadLine()
    End Sub


    Sub Main()
        Module1.Form()
        Try
            ch = per > 0 And per < 100
            If ch Then
                Console.WriteLine("Form Filled Sucessfully")
            Else
                Throw New Exception("Invalid-Range")
            End If
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
        Console.ReadKey()
    End Sub

End Module




Output:


Previous
Next Post »