Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Write a simple For Loop that asks how many times they would like to display a certain message. On entering this number the program then prints out the message that many times.

What I have tried:

I have tried various ways but i just dont understand it how do i do it please
Posted
Updated 11-Oct-17 1:08am
v2

1 solution

This is your homework: so I'll give you no code!

But this is pretty simple, if you read your notes from the last lesson.
There are two sections to this:
1) Ask the user how many times to print the message, and get the response as a number.
2) Loop that many times to print the message.

Now, I'm pretty sure you can print a message, and I'm reasonably sure you have been told how to read a response. Converting that to a number isn't complicated either: Int32.TryParse Method (String, Int32) (System)[^] will do it for you.

So all you need to to is a For loop. Again, that's simple: For...Next Statement (Visual Basic) | Microsoft Docs[^] - there are examples at the bottom of the page which pretty much do exactly what you want!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900