# Making something repeat until the correct input is put in.

• ### Question

• I'm making a text based game. I was wondering if I could make something repeat until the correct input is put in. This is what I have. I want it to repeat until the player says north.

thanks for the help!

TextWindow

.WriteLine("First is movement. Type north to go north, east to go east, west to go west and south to go south. Try it. Go north!")

If

n = "north" Or n = "North" then

n = 1

else

n = 0

endif

If(n = "1") Then

TextWindow.WriteLine("You are in another grassland area. there is a sign.")

TextWindow.WriteLine("The sign says good job!")

Else

TextWindow.WriteLine("Try that again. Go north. Remember, type north to go north.")

EndIf

Monday, November 3, 2014 11:36 PM

• Here you go! Just use a goto statement!

```TextWindow.WriteLine("First is movement. Type north to go north, east to go east, west to go west and south to go south. Try it. Go north!")
Redo: '<-- this is the redo label'

If n = "north" Or n = "North" then
n = 1
else
n = 0
endif
If(n = "1") Then
TextWindow.WriteLine("You are in another grassland area. there is a sign.")
TextWindow.WriteLine("The sign says good job!")
Else
TextWindow.WriteLine("Try that again. Go north. Remember, type north to go north.")
Goto Redo '<-- Telling the program to go back to redo'
EndIf```

It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

• Edited by Tuesday, November 4, 2014 11:59 PM
• Marked as answer by Wednesday, November 5, 2014 9:30 PM
Tuesday, November 4, 2014 11:59 PM

### All replies

• ```Sub AskDirection
n = ""
While n<>"N" And n<>"S" And n<>"W" And n<>"E"
TextWindow.WriteLine("Which way? Hit (N)orth, (S)outh, (W)est or (E)ast")
EndWhile
EndSub

TextWindow.WriteLine(n)```

Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

• Marked as answer by Tuesday, November 4, 2014 4:16 AM
• Unmarked as answer by Tuesday, November 4, 2014 4:16 AM
• Marked as answer by Tuesday, November 4, 2014 4:16 AM
• Unmarked as answer by Tuesday, November 4, 2014 10:36 PM
Tuesday, November 4, 2014 12:15 AM
• I put this in. When I pressed n, the program would suddenly stop. I would actually rather like to have something that will output it and then I customize it to perform the selected action manually. Also, I would like for the user to have to press enter for it to perform this.

Finally, could you explain what you did on the next one so I can learn from it not just copy it down and have to ask for help every time? If you could, that would be highly appreciated.

Thanks again.

• Edited by Tuesday, November 4, 2014 10:45 PM
Tuesday, November 4, 2014 10:42 PM
• Here you go! Just use a goto statement!

```TextWindow.WriteLine("First is movement. Type north to go north, east to go east, west to go west and south to go south. Try it. Go north!")
Redo: '<-- this is the redo label'

If n = "north" Or n = "North" then
n = 1
else
n = 0
endif
If(n = "1") Then
TextWindow.WriteLine("You are in another grassland area. there is a sign.")
TextWindow.WriteLine("The sign says good job!")
Else
TextWindow.WriteLine("Try that again. Go north. Remember, type north to go north.")
Goto Redo '<-- Telling the program to go back to redo'
EndIf```

It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

• Edited by Tuesday, November 4, 2014 11:59 PM
• Marked as answer by Wednesday, November 5, 2014 9:30 PM
Tuesday, November 4, 2014 11:59 PM
• Thank you so much!

Also, for the goto keywords do you just put hat you want and a colon, like this

word:

Wednesday, November 5, 2014 9:31 PM
• Yep! Thats all you do!

It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

Thursday, November 6, 2014 9:09 PM