On Thu, 13 Dec 2012, Tobias Boege wrote: > On Thu, 13 Dec 2012, Bruce wrote: > > The situation is: > > > > We either know that a particular horse was foaled (born) on or > > after year 2000 or we don't know which year it was foaled in, > > i.e. the value on the database for the foaled year is either > > something >=2000 or zero. > > > > The problem is: > > I am trying to use a spinbox to allow the user to enter the > > foaled year. To make it "easier" or "go faster" the minimum > > value of the spinbox should be 2000 and the maximum should be > > Year(Now()). But there is a requirement that if the horse's > > foaling date is not known then the user should be able to select > > 0 in the spinbox. > > > > Obviously, setting the spinbox minumum to 0 doesn't help when > > the foaling year is 2010 as they have to mouse wheel for a > > considerable time before setting it to a known value. I've > > tried using a checkbox next to the spinbox for "unknown" but it > > at best it looks messy (and the resultant code stinks). > > > > They wouldn't have to wheel if they could _type_ ;-) > > > By the way, I choose not use a date picker or a calendar control as the > > only data of interest is the year. > > > > As per the subject, anyone got any good ideas? > > Let's face the truth: if you want to display "0" the [MinValue; MaxValue] > must include 0 as it would otherwise be rejected and you can't force any > text via the Text property or suchlike. > > So I suggest MinValue = 0, MaxValue = Year(Now()) and this (hopefully not > too messy) code: > > Public Sub SpinBox1_Change() > If SpinBox1.Value = 1999 Then > SpinBox1.Value = 0 > Endif > If SpinBox1.Value And SpinBox1.Value < 2000 Then > SpinBox1.Value = 2000 > Endif > End
Errm, that code had leftovers from a different, non-working approach. This may be better: If SpinBox1.Value = 1999 Then SpinBox1.Value = 0 Else If SpinBox1.Value = 1 Then SpinBox1.Value = 2000 Endif ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user