I've been reading exemples on the AHK forums and archives.
Someone made a genious little gLabel to create an Edit Gui Control with this format: numbers only / decimal dot allowed / 2 decimal max
My question is: How to add the possibilities to allow negative sign at the beginning of the value??
like this: -10.50
Code: Select all
Gui, Add, Edit, x85 y10 w80 h20 hwndhMyText vMyText gOnChangeMyText +right
Gui, Show
return
GuiClose:
ExitApp
return
OnChangeMyText:
Gui, Submit, NoHide
if RegExMatch(MyText, "[^\d\.]|\..*\.|\.\d{3,}|^0$") ; <<---------
{
ControlGet, cursorPos, CurrentCol,, %MyText%, A ; Get current cursor position
MyText:=Round(MyText,2)
GuiControl, Text, MyText, %prevText% ; Write text back to Edit control
cursorPos := cursorPos - 2
SendMessage, 0xB1, cursorPos, cursorPos,, ahk_id %hMyText% EM_SETSEL ; Add hwndh to Edit control for this to work
}
else
prevText := MyText
return
I've been trying to add things in the regex detection but it doesnt work as intended.
Any help would eb appreciated
Edit: if someone can help me interpret the RegEx it help me figure out for next times. Its pretty confusing lol
thanks alot!
EDIT: After following the posts, I ended-up to another problem which is, how to calculate the Table Total values WHEN some of the values are empty!?
Doing the maths with integers mixed with empty strings will give error rather than 0 + integers