Sign in to follow this  
Followers 0
RichardT

String Verify

10 posts in this topic

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..."

Share this post


Link to post
Share on other sites

#2 ·  Posted (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

:mellow:

Edited 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.

Share this post


Link to post
Share on other sites

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..."

Share this post


Link to post
Share on other sites

Could you show us all of your code? Inclusive GUI? :mellow:


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.

Share this post


Link to post
Share on other sites

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..."

Share this post


Link to post
Share on other sites

::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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites
:mellow:

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.

Share this post


Link to post
Share on other sites

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..."

Share this post


Link to post
Share on other sites

You realise you didn't post the GUI right?

Share this post


Link to post
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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)

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