Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Imput Mask = 99:99!!
Message
De
04/09/1998 10:06:32
 
 
À
04/09/1998 04:49:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00132790
Message ID:
00133269
Vues:
24
>>>>>>I want to use a ch6 field to represent a time value.
>>>>>>I would like to use the imputmask of 99:99!!.
>>>>>>for example 12:45PM. I want to force the !! to
>>>>>>be either AM or PM. any ideas? thanks :)
>>>>>Rob,
>>>>>Keypress, ,nteractivechange ?
*keypress
>>>>>if this.selstart = 6
>>>>>   nodefault
>>>>>   if inlist(nKeyCode,asc("A"),asc("a"),asc("P"),asc("p"))
>>>>>      This.value = this.value + upper(chr(nKeyCode))+"M"
>>>>>   endif
>>>>>endif
Hope works. Not tested.
>>>>>Cetin
>>>>----------
>>>>Good morning Cetin and thanks for your reply,
>>>>Lets talk about your code:
>>>>
>>>>if this.selstart = 6 && is selstart meanig the time field? and the AM/PM
>>>>would be on the 5th and 6th positions of the field. Not sure how you
>>>>are testing for both positions.
>>>>
>>>> nodefault && why are you using this?
>>>>
>>>>
>>>> if inlist(nKeyCode,asc("A"),asc("a"),asc("P"),asc("p"))
>>>> This.value = this.value + upper(chr(nKeyCode))+"M"
>>>> endif
>>>>endif
>>>
>>>Rob,
>>>Corrected code first :
* Keypress of your textbox (time)
>>>LPARAMETERS nKeyCode, nShiftAltCtrl
>>>if this.selstart = 5 and between(nKeyCode,32,126)
>>>	nodefault
>>>	if inlist(nKeyCode,asc("A"),asc("a"),asc("P"),asc("p"))
>>>		this.value = substr(this.value,1,5) + upper(chr(nKeyCode))+"M"
>>>		this.selstart = 7
>>>	endif
>>>endif
>>>if this.selstart > 5 and between(nKeyCode,32,126)
>>>   nodefault
>>>endif
If at position after second min digit (selstart=5) and key pressed is an alphanumeric (between..) then only let to press "A","a","P","p". Nodefault is to "absorb" other presses. Between check is necessary for disabling our code for backspace, del, arrows etc. (so it in fact should have a default value or "AM" or "PM"-user might just press enter there). Now if we intercept one of those keys, it will be AM or PM, so set value appropriately (this.value ...) and set selstart just after the "M". The second check is for absorbing alphanumeric passed selstart = 5.
>>>Cetin
>>------
>>ok - great! it works. That takes care of the AM/PM part. Now I need
>>to make sure the users enter in a valid time for positions of 1,2,3,4.
>>My format is 99:99. example 12:45PM.. any ideas on this?
>Rob,
>For simplicity I wouldn't check it until valid or lostfocus. Then I would add 12 if pm and convert to datetime then back to ttoc and put value there. If after coversion it returns an empty datetime value I would return .f. in valid or simply do nothing and place empty value there.
>I also read John's code. Nice it will work with some furnishing.
>But after all if you don't really have screen real estate problem why not use a datetime type control.
>Cetin
-------
Good Morning Cetin and thanks for your reply. Screen real estate problem is funny. I do not have screen real estate problems, but the government form
this program prints out on is a problem. I only have room for 99:99 !! or
example.. 11:30 AM...
Robert Keith
Independent Developer
San Antonio, Texas
E-mail address:
rebelrob1@yahoo.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform