Sign in to follow this  
Followers 0
lyledg

msgbox result

8 posts in this topic

Guys

How to I get the result from a "Yes, No" msgbox?

What I am trying to do is if a user clicks "No", it mus loop back to the original code, but if they click "Yes", continue the rest of code?

I am going insane!

:):)

Share this post


Link to post
Share on other sites



Look in the help file.

It contains information that helps you with all the functions.

Share this post


Link to post
Share on other sites

Try to use functions. For example:

; Script start
;...blah blah...

;Here is the function you want to be repeated if the user presses No...
MyFunc()

;MsgBox goes here
$test = MsgBox(4,"Title","Press YES to continue or NO to repeat the last step")
If $test = 7 Then; 7 means "NO" was pressed
   MyFunc()
EndIf

...rest of code goes here...; means the user has pressed YES

; End of your code

Func MyFunc()
  ;here
  ;is your function's code
EndFunc

; End of script

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here's what you need form the MsgBox() topic in the helpfile ..

Return Value

Success: Returns the ID of the button pressed.

Failure: Returns -1 if the message box timed out.

Return Value  Button Pressed

1 = OK 

2 = CANCEL 

3 = ABORT

4 = RETRY

5 = IGNORE 

6 = YES 

7 = NO 

10 = TRY AGAIN ** 

11 = CONTINUE ** 

HTH :)

Edit: Sample code:

( :) .. there's none in the helpfile! <-- opportunity for enhancement, someone?)

;stuff before the question
   ;stuff before the question
   ;stuff before the question

    While MsgBox(4096 + 4 + 32,@ScriptName,"Ready to continue?") = 7  ; 7 = NO
        sleep(10)
    Wend

   ;continue stuff
   ;continue stuff
   ;continue stuff
Edited by trids

Share this post


Link to post
Share on other sites

I assume that he probably wanted a way to "goto" his code...

Not quite sure though :)

Share this post


Link to post
Share on other sites

What I am trying to do is if a user clicks "No", it mus loop back to the original code, but if they click "Yes", continue the rest of code?

$Yes = 6
$No = 7
;Your code here

;Prompt user for an answer
$Answer = MsgBox(64 + 3, @ScriptName, "Do you want to exit?")
If $Answer = $Yes Then
  ;Do stuff
   Exit;if you want
ElseIf $Answer = $No Then
  ;Do stuff
EndIf

Share this post


Link to post
Share on other sites

I assume that he probably wanted a way to "goto" his code...

<{POST_SNAPBACK}>

You're right - I was just being lazy :)

Here's the reason we don't need GOTOs ..

Do ; <-- equivalent of a GOTO destination
       ;stuff until user says YES
       ;stuff until user says YES
       ;stuff until user says YES
       ;stuff until user says YES
    Until MsgBox(4096 + 4 + 32,@ScriptName,"Ready to continue?") = 6  ; 6 = YES

Share this post


Link to post
Share on other sites

Thanks Guys, you all have helped HEAPS!! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0