ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to read a name and print 5 times using GoTo statement

Here, we are going to learn how to read a name and print 5 times using GoTo statement in VB.Net?
Submitted by Nidhi, on December 03, 2020

Here, we will read a string from the user and print the entered name 5 times on the console screen.

Program/Source Code:

The source code to read a name and print 5 times using the "GoTo" statement is given below. The given program is compiled and executed successfully.

'VB.Net program to read a name and 
'print 5 times using "GoTo" statement.

Module Module1
    Sub Main()
        Dim name As String
        Dim count As Integer = 0

        Console.Write("Enter Name: ")
        name = Console.ReadLine()

MyLabel:
        count = count + 1

        If count <= 5 Then
            Console.WriteLine("Name: {0}", name)
            GoTo MyLabel
        End If

    End Sub
End Module

Output:

Enter Name: Rahul
Name: Rahul
Name: Rahul
Name: Rahul
Name: Rahul
Name: Rahul
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a Main() method. In the Main() method, we created three variables name and count. Then we created the label MyLabel, which is used to transfer program control using the "GoTo" statement. 

After that, we read the name from the user and then printed the entered name 5 times 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.