Idc Posted October 29, 2009 Posted October 29, 2009 I need help . It is my code :$x = InputBox("Hi","Your Value:","20") If $x >= 0 Then MsgBox(48,"Your value",$x + 1387.4) Else msgbox(48,"Error","error") EndIfWhen i run it, if i press OK button it run very good but if i press cancel button it also show that value . So what should i do ?? :-s . (i have just learned autoit for 3 days )
bo8ster Posted October 29, 2009 Posted October 29, 2009 Thats because you are doing empty string plus "1387.4". AutoIt is casting it into a string and appending it. Check for "" being returned by the InputBox. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
Mecrazycoder Posted October 29, 2009 Posted October 29, 2009 I need help . It is my code : $x = InputBox("Hi","Your Value:","20") If $x >= 0 Then MsgBox(48,"Your value",$x + 1387.4) Else msgbox(48,"Error","error") EndIf When i run it, if i press OK button it run very good but if i press cancel button it also show that value . So what should i do ?? :-s . (i have just learned autoit for 3 days ) Try this $x = InputBox("Hi","Your Value:","") If @error=1 Then msgbox(48,"Error","error") $x=-1 EndIf If $x >= 0 Then MsgBox(48,"Your value",$x + 1387.4) EndIf [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]
bo8ster Posted October 29, 2009 Posted October 29, 2009 Try this $x = InputBox("Hi","Your Value:","") If @error=1 Then msgbox(48,"Error","error") $x=-1 EndIf If $x >= 0 Then MsgBox(48,"Your value",$x + 1387.4) EndIf The same issue will occur if OK is pressed with no text. Try this: Local $x = InputBox("Hi","Your Value:","") If $x == "" Then msgbox(48,"Error","error") $x=-1 EndIf If $x >= 0 Then MsgBox(48,"Your value",$x + 1387.4) EndIf Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
Mecrazycoder Posted October 29, 2009 Posted October 29, 2009 The same issue will occur if OK is pressed with no text. Try this: Local $x = InputBox("Hi","Your Value:","") If $x == "" Then msgbox(48,"Error","error") $x=-1 EndIf If $x >= 0 Then MsgBox(48,"Your value",$x + 1387.4) EndIf Yeah you are right.I didn't test my code... [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now