Get with Spinner Question

Post Reply
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Get with Spinner Question

Post by Jeff Barnes »

Hi Everybody,

I have a get (see below) that I want only entries from 8 to 120 in increments of 4. The only problem I have is that the user can manually type in a number that is not divisible by 4 (ex. they type 29)

How can I prevent the user from either manually entering a number (I still want them to use the spinner) or not accept a value unless it is divisible by 4 ??


Code: Select all

REDEFINE GET oGet  var nNumber  id 102 of oDlg PICTURE "999" ;
     SPINNER MIN 8 MAX 120  UPDATE
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Jeff,

You can use the VALID clause for that purpose, as usual.

Just do the required checks from the VALID
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Jeff,

I think that the best control will not let the user enter an invalid number. I want to avoid telling the user that he/she has done something "wrong."

How about using a combobox instead. It has an incremental search that won't let the user enter an invaid value and you can preload it with the 30 valid values.

Another disadvange of a spinner is that user might have to click on it 30 times to get to the highest value.

Regards,
James
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

Hi James / Antonio,

Thanks for the replies.

I ended up using the MOD() function ... if there is a remainder then the number is not divisible by 4 :)

I just remember the last value and populate the field with it if the number entered number is invalid.
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
Post Reply