Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when i write for example : GTA 4
it writes "GTA 4 is your favorite game!"
but if i write another answer it doesn't do anything
because the case ended
How can i solve this

What I have tried:

Dim game As String


Console.WriteLine("Your favourite game?")
game = Console.ReadLine()


Dim message As String
message = game & " is your favourite game!"

Select Case game
Case "GTA 4"
Console.WriteLine(message)
Case "Battlefield 3"
Console.WriteLine(message)
Case "GRID"
Console.WriteLine(message)
Case "Infamous"
Console.WriteLine(message)
Case Else
Console.WriteLine("Looks like your game is not on my list")
End Select
Console.ReadLine()
Posted
Updated 4-Nov-17 14:09pm
v2

Use a For loop or a While loop to keep accepting input until the user enters something like "Stop"
 
Share this answer
 
Comments
THE-CODER-SALEH 4-Nov-17 16:37pm    
i tried loop before but it keeps giving me the same answer
for example : if i type "GTA 4" it gives me
"GTA 4 is your favorite game!"
and when i type another answer like "Battlefield 3" it gives me
"GTA 4 is your favorite game!" too
maybe i put "loop" in the the wrong place
can you add it to my code and put in a comment
Thanks
CHill60 4-Nov-17 18:27pm    
Use the "Improve question" link to show how you used a loop and we can help you fix it
THE-CODER-SALEH 4-Nov-17 19:27pm    
thank you it worked
This is the solution :


Dim game As String

Do

Console.WriteLine("Your favourite game?")
game = Console.ReadLine()


Dim message As String
message = game & " is your favourite game!"

Select Case game
Case "GTA 4"
Console.WriteLine(message)
Case "Battlefield 3"
Console.WriteLine(message)
Case "GRID"
Console.WriteLine(message)
Case "Infamous"
Console.WriteLine(message)
Case Else
Console.WriteLine("Looks like your game is not on my list")
End Select
Loop
 
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