Jump to content

InputBox Buttons


Yar
 Share

Recommended Posts

On the Function InputBox page from the documentation, it says that if the Cancel button is pushed, the value returned will be 1. Can someone verify that this works? Because I have in my code that if the Cancel button is pushed (and 1 is returned as $input), then the program will exit.

CODE
$input = InputBox ("Helper", "What would you like to know?", "" , "" , 200, 30, 0, 0)

If $input = 1 Then

Exit

ElseIf $input = "" Then

$box = MsgBox (0, "Helper", "Please give an answer")

If $box = 1 Then

$input = InputBox ("Helper", "What would you like to know?", "" , "" , 200, 30, 0, 0)

EndIfEndIf
Link to comment
Share on other sites

On the Function InputBox page from the documentation, it says that if the Cancel button is pushed, the value returned will be 1. Can someone verify that this works? Because I have in my code that if the Cancel button is pushed (and 1 is returned as $input), then the program will exit.

CODE
$input = InputBox ("Helper", "What would you like to know?", "" , "" , 200, 30, 0, 0)

If $input = 1 Then

Exit

ElseIf $input = "" Then

$box = MsgBox (0, "Helper", "Please give an answer")

If $box = 1 Then

$input = InputBox ("Helper", "What would you like to know?", "" , "" , 200, 30, 0, 0)

EndIfEndIf
it is the @error that returns the "1" you should write it :

if @error=1 then...


            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


Yar
            
            
                Posted 
                
            
        
    
    
        


Yar
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Members
                
            
            
                
                    
                        
                            
                                
                            
                                 12
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                        Author
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            Ahh, I misunderstood it then. Thank you very much.


            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


GEOSoft
            
            
                Posted 
                
            
        
    
    
        


GEOSoft
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                MVPs
                
                    
                
            
            
                
                    
                        
                            
                                
                            
                                 10.3k
                            
                                
                            
                        
                        
                    
                
            
            
                

    
    
        
Sure I'm senile. What's your excuse?
    
    

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            On the Function InputBox page from the documentation, it says that if the Cancel button is pushed, the value returned will be 1. Can someone verify that this works? Because I have in my code that if the Cancel button is pushed (and 1 is returned as $input), then the program will exit.


CODE$input = InputBox ("Helper", "What would you like to know?", "" , "" , 200, 30, 0, 0)

If $input = 1 Then
ExitElseIf $input = "" Then
$box = MsgBox (0, "Helper", "Please give an answer")
If $box = 1 Then
$input = InputBox ("Helper", "What would you like to know?", "" , "" , 200, 30, 0, 0)EndIfEndIfThat's not what the help file says.  What is does say is that @Error will be set to 1.
Replace your code with
While NOT @Error
   $input = InputBox ("Helper", "What would you like to know?", "" , "" , 200, 30, 0, 0)
   If @Error = 1 Then Exit
   If $input = "" Then
      $box = MsgBox (0, "Helper", "Please give an answer")
      ContinueLoop
   Else
      ExitLoop
   EndIf
Wend

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...