sankar18 Posted July 22, 2013 Posted July 22, 2013 Hi Everyone, I want to validate the textbox contain only floating point values which always in "xxx.xx" formate 3 digit and after "." two digit. i try this Global $iicd1 = GUICtrlCreateInput("", 208, 310, 60, 20,$ES_Number) GUICtrlSetLimit(-1, 6) but didn't get "." any one please look on this and do the needful thank in advance
Bert Posted July 22, 2013 Posted July 22, 2013 (edited) Would you be so kind in posting your script? We do not have mind reading capabilities nor can we hack into your PC to read your code. Without your script, we have no idea how to help you. Edited July 22, 2013 by YogiBear The Vollatran project My blog: http://www.vollysinterestingshit.com/
abberration Posted July 22, 2013 Posted July 22, 2013 I searched the forum for a similar example and found one by martin and modifed it to perform about how you would like. The only problem with this code is backspacing to delete the "." does not work. I'm trying to figure it out. Here's what I have so far: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") $gui = GUICreate("Gui", 300, 100) $IP = GUICtrlCreateInput("", 10, 40, 200, 22, $ES_NUMBER) GUICtrlSetLimit($IP, 6) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) If $nID = $IP Then $hCtrl = $lParam If $nNotifyCode = $EN_CHANGE Then $txt = GUICtrlRead($IP) If StringLen($txt) = 3 Then $newtxt = $txt & "." GUICtrlSetData($IP, $newtxt) EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Easy MP3 | Software Installer | Password Manager
abberration Posted July 22, 2013 Posted July 22, 2013 I think this will work: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <editconstants.au3> #include <Misc.au3> GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") $gui = GUICreate("Gui", 300, 100) $IP = GUICtrlCreateInput("", 10, 40, 200, 22, $ES_NUMBER) GUICtrlSetLimit($IP, 6) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) If $nID = $IP Then $hCtrl = $lParam If $nNotifyCode = $EN_CHANGE Then $txt = GUICtrlRead($IP) Local $hDLL = DllOpen("user32.dll") If _IsPressed("08", $hDLL) AND StringLen($txt) = 4 Then $newtxt = StringTrimRight($txt, 1) GUICtrlSetData($IP, $newtxt) ElseIf StringLen($txt) = 3 Then $newtxt = $txt & "." GUICtrlSetData($IP, $newtxt) EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Easy MP3 | Software Installer | Password Manager
czardas Posted July 22, 2013 Posted July 22, 2013 Local $sFloat = "123.45" If StringRegExp($sFloat, "\A\d{3}\.\d{2}\z") Then MsgBox(0, "Msg", $sFloat & " = Valid Input") operator64 ArrayWorkshop
czardas Posted July 23, 2013 Posted July 23, 2013 The regular expression should work. I didn't try abberration's code, but I think it's much easier to allow the user to type whatever they like and only validate the input after they click the Okay button. Good luck with it. operator64 ArrayWorkshop
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