VB.Net program to demonstrate the StackOverflowException

Here, we are going to demonstrate the StackOverflowException in VB.Net.
Submitted by Nidhi, on January 05, 2021

Here, we will demonstrate the StackOverflowException, this exception will be generated by the infinite recursive function call.

Program/Source Code:

The source code to demonstrate the StackOverflowException is given below. The given program is compiled and executed successfully.

'Vb.Net program to demonstrate the StackOverflowException

Module Module1
    Dim num As Integer = 10000
    Sub RecursiveFun()

        num = num + 10000
    End Sub

    Sub Main()
        Catch e As StackOverflowException
        End Try
    End Sub
End Module


Process is terminated due to StackOverflowException.
Press any key to continue . . .


In the above program, here we created a module Module1. The Module1 contain two functions RecursiveFun(), Main() function.

The RecursiveFun() function has an infinite recursive call that's why it will generate StackOverflow Exception.

The Main() is the entry point for the program, here we called the RecursiveFun() function that will be caught in the catch block and print an appropriate message on the console screen.

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.