Get with Spinner Question

Get with Spinner Question

Postby Jeff Barnes » Fri Mar 07, 2008 11:14 pm

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  Expand view  RUN
REDEFINE GET oGet  var nNumber  id 102 of oDlg PICTURE "999" ;
     SPINNER MIN 8 MAX 120  UPDATE
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Antonio Linares » Sat Mar 08, 2008 12:31 am

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
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Sat Mar 08, 2008 12:46 am

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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Jeff Barnes » Sat Mar 08, 2008 3:14 pm

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 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Otto and 26 guests