RichardT Posted June 2, 2010 Share Posted June 2, 2010 All, I have a simple question (I think). I have a input field that captures a users input ($sInput). I want to make sure that the user inputs only numbers not letters. Here is my code: $sInput = GUICtrlRead($sCapture) ;Checks to see if $sInput is a valid String IsString($sInput) $sX = StringFormat( "%.0d", 2 ) If $sX = @error =1 Then _FileWriteLog($sLogfile, "") _FileWriteLog($sLogfile, "Error - Engine Number Format is not Correct") SplashOff() MsgBox(0, "Error", "Engine Number Format is not Correct") GUICtrlSetState($sCapture, $GUI_FOCUS) EndIf I want it to return to the input field to try again (thus the GUICtrlSetState($sCapture, $GUI_FOCUS) but it doesn't do anything? Please help... RichardT "so much work, so little brains..." Link to comment Share on other sites More sharing options...
AlmarM Posted June 2, 2010 Share Posted June 2, 2010 (edited) To allow only numbers inside a input use: #include <EditConstants.au3> $sInput = GUICtrlCreateInput(10, 10, 100, 20, $ES_NUMBER) Also If IsString(GUICtrlRead($sInput)) Then Edited June 2, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
RichardT Posted June 2, 2010 Author Share Posted June 2, 2010 AlmarM Thanks for the reply. Unfortunately, I cannot get it to work. Maybe I am puting it into the wrong spot. I use the $sCapture as the variable I assign to the GUICTRLInput. So I have two questions, 1: How whould I use the first suggestion 2: How whould I format the If statement you specified based on the code I posted? Will it use the StringFormat command also? Thanks RichardT "so much work, so little brains..." Link to comment Share on other sites More sharing options...
AlmarM Posted June 2, 2010 Share Posted June 2, 2010 Could you show us all of your code? Inclusive GUI? Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
RichardT Posted June 3, 2010 Author Share Posted June 3, 2010 Here is the GUI program. It is large. It programs a Access point at then end, that is why there are so many "Send" commands. As a side note, I do not know why that after I engage the connect function, why does it run the entire function over again, even though it was successful? "so much work, so little brains..." Link to comment Share on other sites More sharing options...
jchd Posted June 3, 2010 Share Posted June 3, 2010 ::ahem:: This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
AlmarM Posted June 3, 2010 Share Posted June 3, 2010 Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
RichardT Posted June 3, 2010 Author Share Posted June 3, 2010 I failed to tell who helped me the most with the code. I was JCHD. That guy can code! So if it looks professional, he did it! "so much work, so little brains..." Link to comment Share on other sites More sharing options...
Tvern Posted June 3, 2010 Share Posted June 3, 2010 You realise you didn't post the GUI right? Link to comment Share on other sites More sharing options...
jchd Posted June 3, 2010 Share Posted June 3, 2010 Hi RichardT, I didn't "cough" to have my name on the front stage, I don't care. Since you PMed me that your stuff was corporate stuff and preferably not public, I reminded you that I'm standing behind my humble contribution. I'm not saying I'm the only one on Earth able to help you with this, but as I lastly said, feel free to chime if you have any issue. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
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