ADVERTISEMENT
ADVERTISEMENT

VB.Net program to read a name and print 5 times using the Do Loop While

Here, we are going to learn how to read a name and print 5 times using the Do Loop While in VB.Net?
Submitted by Nidhi, on December 06, 2020

Here, we will read a number from the user and then print the entered name 5 times using the Do Loop While loop on the console screen.

Program/Source Code:

The source code to read a name and print 5 times using the Do Loop While loop is given below. The given program is compiled and executed successfully.

'VB.Net program to read a name and print 5 times 
'using "Do Loop While" loop.

Module Module1

    Sub Main()
        Dim name As String = ""
        Dim count As Integer = 1

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

        Do
            Console.WriteLine("{0} ", name)
            count = count + 1
        Loop While count <= 5

        Console.WriteLine()
    End Sub

End Module

Output:

Enter Name: Shikar Dhawan
Shikar Dhawan
Shikar Dhawan
Shikar Dhawan
Shikar Dhawan
Shikar Dhawan

Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a function Main(). In the Main() we created two variables name and count, here variable name is initialized with an empty string, and the variable count is initialized with 1.

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

Do

    Console.WriteLine("{0} ", name)
    count = count + 1
Loop While count <= 5

In the above code, we used the counter variable count to execute the loop 5 times and, here we read a name from the user and then print the name 5 times using the Do Loop While loop.

VB.Net Basic Programs »



ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

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.