ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to overload Main() function

Here, we are going to learn how to overload Main() function in VB.Net?
Submitted by Nidhi, on December 25, 2020

Here, we will overload the Main() function based on different number arguments, but the Main() function with string array argument is the entry point for the program.

Program/Source Code:

The source code to overload the Main() function is given below. The given program is compiled and executed successfully.

'VB.net program to overload Main() function.

Module Module1
    Sub Main(ByVal val As Integer)
        Console.WriteLine("Val : {0}", val)
    End Sub
    
    Sub Main(ByVal val As Double)
        Console.WriteLine("Val : {0}", val)
    End Sub

    Sub Main(ByVal args As String())
        Main(10)
        Main(22.67)
    End Sub
End Module

Output:

Val : 10
Val : 22.67
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1. Here, we created three Main() functions.

The Main() function with the string array argument is the entry point for the program. Here, we called both overloaded methods that will print the argument passed into the function on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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.