Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Input box with a loop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aimee209 - 04 Mar 2008 12:37 GMT
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!
Mike H - 04 Mar 2008 12:50 GMT
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

> 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
[quoted text clipped - 6 lines]
>
> Thanks!
Mike H - 04 Mar 2008 12:58 GMT
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

> 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
[quoted text clipped - 6 lines]
>
> Thanks!
aimee209 - 04 Mar 2008 13:06 GMT
Thanks!  I tried the first response with the goto retry and that seems to be
working!

> 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
[quoted text clipped - 6 lines]
>
> Thanks!
Mike H - 04 Mar 2008 13:12 GMT
Your welcome and thanks for the feed back.

> Thanks!  I tried the first response with the goto retry and that seems to be
> working!
[quoted text clipped - 9 lines]
> >
> > Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.