WD20 - input mask for time > 24 hours

Startbeitrag von Arie am 08.04.2016 09: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).

Antworten:

Hi Arie,

Are you looking for the Duration control?

http://help.windev.com/en-US/?1014019

von DarrenF - am 08.04.2016 09:58
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

von Mike H - am 08.04.2016 11:26
Hoi Arie,

Take a look at this tool, it is free!
http://ultrapico.com/ExpressoFeatures.htm


regards
Allard

von Allard - am 08.04.2016 12:51
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


von Arie - am 08.04.2016 14:30
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.

von Mike H - am 09.04.2016 05:16
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.