Sign in to follow this  
Followers 0
Yar

InputBox Buttons

5 posts in this topic

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

Share this post


Link to post
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...


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
Yar   

    
        
    
             0
    
        
    

        
            
                Seeker
            
            

            
                

    
        
    

            
            Members
            
            
                

    
        
    
             0
    
        
    

                12 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #4 · 
            Posted 
            
            
            
        
    

    


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


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
GEOSoft   

    
        
    
             63
    
        
    

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

            
                

    
        
    

            
            MVPs
            
                
            
            
                

    
        
    
             63
    
        
    

                10,348 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #5 · 
            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!"

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