Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Input box with a loop

I have an input box that pops up and asks a question. If the user enters the
correct answer, a message box will show saying that's correct, and after
clicking ok move on to the next question.
Right now, when the user enters the wrong answer, a message box saying
that's incorrect shows, but then it moves on to the next question when ok is
clicked. Is there a way to do a loop so that when the incorrect answer is
selected, the original question reappears instead of going to the next
question?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Input box with a loop

Hi,

A look at your code would have been helpful but here's one way

Sub liminal()
retry:
response = InputBox("What is the meaning of Life?")
If response < 42 Then
response1 = MsgBox("Now that's incorrect, please re-read the book",
vbRetryCancel)
If response1 = vbRetry Then GoTo retry
Else
MsgBox "Well done, the meaning of life is " & response
End If
End Sub

Mike

"aimee209" wrote:

I have an input box that pops up and asks a question. If the user enters the
correct answer, a message box will show saying that's correct, and after
clicking ok move on to the next question.
Right now, when the user enters the wrong answer, a message box saying
that's incorrect shows, but then it moves on to the next question when ok is
clicked. Is there a way to do a loop so that when the incorrect answer is
selected, the original question reappears instead of going to the next
question?

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Input box with a loop

And with a loop

Sub versives_R_us()
Do
response = InputBox("What is the meaning of Life?")
If response < 42 Then
response1 = MsgBox("Now that's incorrect, please re-read the book",
vbRetryCancel)
Else
MsgBox "Well done, the meaning of life is " & response
End If
Loop Until response = 42 Or response1 = vbCancel
End Sub

Mike

"aimee209" wrote:

I have an input box that pops up and asks a question. If the user enters the
correct answer, a message box will show saying that's correct, and after
clicking ok move on to the next question.
Right now, when the user enters the wrong answer, a message box saying
that's incorrect shows, but then it moves on to the next question when ok is
clicked. Is there a way to do a loop so that when the incorrect answer is
selected, the original question reappears instead of going to the next
question?

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Input box with a loop

Thanks! I tried the first response with the goto retry and that seems to be
working!


"aimee209" wrote:

I have an input box that pops up and asks a question. If the user enters the
correct answer, a message box will show saying that's correct, and after
clicking ok move on to the next question.
Right now, when the user enters the wrong answer, a message box saying
that's incorrect shows, but then it moves on to the next question when ok is
clicked. Is there a way to do a loop so that when the incorrect answer is
selected, the original question reappears instead of going to the next
question?

Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Input box with a loop

Your welcome and thanks for the feed back.

"aimee209" wrote:

Thanks! I tried the first response with the goto retry and that seems to be
working!


"aimee209" wrote:

I have an input box that pops up and asks a question. If the user enters the
correct answer, a message box will show saying that's correct, and after
clicking ok move on to the next question.
Right now, when the user enters the wrong answer, a message box saying
that's incorrect shows, but then it moves on to the next question when ok is
clicked. Is there a way to do a loop so that when the incorrect answer is
selected, the original question reappears instead of going to the next
question?

Thanks!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
endless loop - using input box [email protected] Excel Programming 2 February 8th 07 04:26 AM
Loop through a range, allow user input during... AD108 Excel Programming 0 December 22nd 06 03:29 PM
Collecting textbox input within a for loop [email protected] Excel Programming 1 May 19th 06 08:01 PM
Loop through for condition and input in adjacent cell bundyloco[_2_] Excel Programming 1 July 13th 05 09:35 AM


All times are GMT +1. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"