|
| WD20 - input mask for time > 24 hours |
| Iniciado por guest, 08,abr. 2016 11:48 - 6 respuestas |
| |
| | | |
|
| |
| Publicado el 08,abril 2016 - 11:48 |
Hi,
I need to input times with hours more than 24. Say an employee worked 123:45 this week, then I would like to enter this value. The reguler time mask HH:MM is ment for max 23:59 time values. I'm not a regexp export. Can anyone give the regular expression for this, which I can use (in with a normal edit-control). |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,abril 2016 - 11:58 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,abril 2016 - 13:26 |
Hi, Arie,
Your reference to a "normal edit control" leads me to think you are envisioning a string edit control.
Here is a sample code you can use at the exit of that edit control
xHr, xMin are string IF MatchRegularExpression(MySelf,"([0-9]{0,3}).([0-9]{0,2})",xHr,xMin)=False THEN Info("Invalid entry"); RETURN Info(xHr+"h "+xMin+("m"))
Some tips on how to read the regular expression: [0-9] means you will accept any numeric digit {0,3} means you expect between 0 and 3 consecutive digits The period I use because it's easier to enter using a numeric pad. You can replace this with a colon if you wish The internal pairs of parenthesis designate the start and end of the strings you want to extract. The first string will be placed in xHr and the second in xMin
Hope this helps |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 34 mensajes |
|
| Publicado el 08,abril 2016 - 14:06 |
Hi Arie,
you could also use 2 fields, one for hours and one for minutes.
The hour field would be an int field (set it with 999 as mask) and the minute field would a time fild (set it with MM as mask) |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,abril 2016 - 14:51 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,abril 2016 - 16:30 |
The duration control displays the entered value as a duration afterwards. Looks a bit odd. The regexp check works when used in the on-exit event. However, what I need is a check WHILE typing.
I'm now using this code in the WM_CHAR event. It may need some tweaks here and there. I also use the on-exit event to complete the entered text, like when the user just types 123 I add :00 to it.
sCheck is string sPart1 is string sPart2 is string nCount is int sCheck = MySelf+Charact(_EVE.wParam) nCount = StringCount(sCheck,":") //trace(_EVE.wParam) // 8=backspace IF _EVE.wParam <> 8 THEN IF NOT _EVE.wParam IN (48,49,50,51,52,53,54,55,56,57,58) THEN RESULT False END IF nCount = 1 THEN IF sCheck[[1]] = ":" THEN RESULT False END sPart1 = ExtractString(sCheck,1,":") IF sPart1 = EOT THEN sPart1 = "" END sPart2 = ExtractString(sCheck,2,":") IF sPart2 = EOT THEN sPart2 = "" END IF sPart1 <> "" THEN IF NOT IsNumeric(sPart1) THEN RESULT False END END IF sPart2 <> "" THEN IF NOT IsNumeric(sPart2) THEN RESULT False END END IF Length(sPart2) > 2 OR Val(sPart2) > 59 THEN RESULT False END ELSE IF nCount = 2 THEN RESULT False END IF NOT IsNumeric(sCheck[[1]]) THEN RESULT False END END END |
| |
| |
| | | |
|
| | |
| |
| Publicado el 09,abril 2016 - 07:16 |
Thanks, Arie
Your sample code was an excellent introduction to how to intercept and handle events below WinDev command level. It might come in handy for future projects. |
| |
| |
| | | |
|
| | | | |
| | |
|