Valid event or Not ?
Hi all,
I have a numeric field and I need to limit the values that the user can put
in i.e. +10 to 10 but it must be in .25 increments how can I do this?
Would I put this in the valid even? And if so what would the code be to check
that it is between +10 and 10? And in .25 increments?
Many thanks
Paul
# 1 Re: Valid event or Not ?
Most of this can be hadled with a Spinner control. Just set the approriate
properties, like the .Increment=.25, the .KeyboardHighValue and
..SpinnerHighValue to 10.00, the .KeyboardLowValue and .SPinnerLowValue
to -10.00 and the initial .Value property to include 2 decimal places, like
0.00.
Then in the .Valid, you could check that it's a valid increment of .25 (in
case someone manually entered a value) with:
IF MOD(this.Value,this.Increment)=0.00
RETURN .T. && Value is an increment of .25
ELSE
* value is not an increment of 25
RETURN 0 && to stay in field, no message or RETURN .F. to stay in
field with VFP message
ENDIF
The Spinner itself will handle the -10.00 to 10.00 and increments of .25.
Note that if someone enters an odd value, like 1.33, then the increment will
take place from there (1.58, 1.08).
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
Paul Summerfield wrote:
> Hi all,
>
> I have a numeric field and I need to limit the values that the user
> can put in i.e. +10 to 10 but it must be in .25 increments how can I
> do this?
>
> Would I put this in the valid even? And if so what would the code be
> to check that it is between +10 and 10? And in .25 increments?
>
> Many thanks
>
> Paul
--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.489 / Virus Database: 288 - Release Date: 6/10/2003
# 2 Re: Valid event or Not ?
Thnaks,
But i have an issue on your last bit" Note that if someone enters an odd
value, like 1.33, then the increment will take place from there (1.58, 1.08)"
My problem is that i only wnat it to be incremented by .25 i.e it has to
be .25, .50 , .75 .00 etc...
So how would i be able to Accomplish this task ?
Thanks in advance
Paul
"Fred Taylor" <ftaylor@mvps.org> wrote:
>Most of this can be hadled with a Spinner control. Just set the approriate
>properties, like the .Increment=.25, the .KeyboardHighValue and
>..SpinnerHighValue to 10.00, the .KeyboardLowValue and .SPinnerLowValue
>to -10.00 and the initial .Value property to include 2 decimal places, like
>0.00.
>
>Then in the .Valid, you could check that it's a valid increment of .25
(in
>case someone manually entered a value) with:
>
>IF MOD(this.Value,this.Increment)=0.00
> RETURN .T. && Value is an increment of .25
>ELSE
> * value is not an increment of 25
> RETURN 0 && to stay in field, no message or RETURN .F. to stay in
>field with VFP message
>ENDIF
>
>
>The Spinner itself will handle the -10.00 to 10.00 and increments of .25.
>Note that if someone enters an odd value, like 1.33, then the increment
will
>take place from there (1.58, 1.08).
>
>
>--
>
>Fred
>Microsoft Visual FoxPro MVP
>Please respond only to the newsgroups so that all may benefit.
>
>
>
>
>Paul Summerfield wrote:
>> Hi all,
>>
>> I have a numeric field and I need to limit the values that the user
>> can put in i.e. +10 to 10 but it must be in .25 increments how can I
>> do this?
>>
>> Would I put this in the valid even? And if so what would the code be
>> to check that it is between +10 and 10? And in .25 increments?
>>
>> Many thanks
>>
>> Paul
>
>
>--
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.489 / Virus Database: 288 - Release Date: 6/10/2003
>
>
# 3 Re: Valid event or Not ?
You'd have to handle the rounding at some point, but that gets to be a
little tricky, especially if you try to handle it in the .InteractiveChange
event.
Otherwise, you might be better off just waiting until the .Valid() and
rounding it there.
nIncs = INT(this.Value/.25)
this.Value = nIncs * .25
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
paul Summerfield wrote:
> Thnaks,
>
> But i have an issue on your last bit" Note that if someone enters an
> odd value, like 1.33, then the increment will take place from there
> (1.58, 1.08)"
>
> My problem is that i only wnat it to be incremented by .25 i.e it has
> to
> be .25, .50 , .75 .00 etc...
>
> So how would i be able to Accomplish this task ?
>
> Thanks in advance
>
> Paul
>
>
>
> "Fred Taylor" <ftaylor@mvps.org> wrote:
>> Most of this can be hadled with a Spinner control. Just set the
>> approriate properties, like the .Increment=.25, the
>> .KeyboardHighValue and ..SpinnerHighValue to 10.00, the
>> .KeyboardLowValue and .SPinnerLowValue
>> to -10.00 and the initial .Value property to include 2 decimal
>> places, like
>> 0.00.
>>
>> Then in the .Valid, you could check that it's a valid increment of
>> .25
> (in
>> case someone manually entered a value) with:
>>
>> IF MOD(this.Value,this.Increment)=0.00
>> RETURN .T. && Value is an increment of .25
>> ELSE
>> * value is not an increment of 25
>> RETURN 0 && to stay in field, no message or RETURN .F. to stay
>> in field with VFP message
>> ENDIF
>>
>>
>> The Spinner itself will handle the -10.00 to 10.00 and increments of
>> .25. Note that if someone enters an odd value, like 1.33, then the
>> increment
> will
>> take place from there (1.58, 1.08).
>>
>>
>> --
>>
>> Fred
>> Microsoft Visual FoxPro MVP
>> Please respond only to the newsgroups so that all may benefit.
>>
>>
>>
>>
>> Paul Summerfield wrote:
>>> Hi all,
>>>
>>> I have a numeric field and I need to limit the values that the user
>>> can put in i.e. +10 to 10 but it must be in .25 increments how can
>>> I
>>> do this?
>>>
>>> Would I put this in the valid even? And if so what would the code be
>>> to check that it is between +10 and 10? And in .25 increments?
>>>
>>> Many thanks
>>>
>>> Paul
>>
>>
>> --
>> Outgoing mail is certified Virus Free.
>> Checked by AVG anti-virus system (http://www.grisoft.com).
>> Version: 6.0.489 / Virus Database: 288 - Release Date: 6/10/2003
--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.489 / Virus Database: 288 - Release Date: 6/10/2003
