Home > Archive > Visual Basic Syntax > March 2005 > Populate a combo box with Years
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Populate a combo box with Years
|
|
|
| Hi everyone, I'm designing an application which requires me to have a combo
box drop down list that has in it a list of previous 100 years, from 1900 to
2000. Now although I could just manually type them in, I would like the
application to automatically update itself as the years go by. Is there a
solution to this issue? If so, how. Please advise.
I'd greatly appreciate.
Thanks in advance
| |
| Rick Rothstein 2005-03-09, 4:01 am |
| > Hi everyone, I'm designing an application which requires me to have a
combo
> box drop down list that has in it a list of previous 100 years, from
1900 to
> 2000. Now although I could just manually type them in, I would like
the
> application to automatically update itself as the years go by. Is
there a
> solution to this issue? If so, how. Please advise.
If you want the ComboBox to have the 100 years from 1900 to 2000 (which
is actually 101 years by the way) and the current year is 2005, what do
you mean by "I would like the application to automatically update itself
as the years go by"? What was different about the last 5 years that you
didn't want an automatic update to take place?
As for putting the years 1900 to 2000 into a ComboBox (assumed to be
named Combo1)
Dim X As Long
Combo1.Clear
For X = 1900 To 2000
Combo1.AddItem CStr(X)
Next
Rick - MVP
| |
| Michael Cole 2005-03-09, 4:01 am |
| Rick Rothstein wrote:
>
> If you want the ComboBox to have the 100 years from 1900 to 2000
> (which is actually 101 years by the way) and the current year is
> 2005, what do you mean by "I would like the application to
> automatically update itself as the years go by"? What was different
> about the last 5 years that you didn't want an automatic update to
> take place?
Perhaps what he means is that as each year goes by, one year is dropped off
and the next added.
In which case, change the following line: -
> As for putting the years 1900 to 2000 into a ComboBox (assumed to be
> named Combo1)
>
> Dim X As Long
> Combo1.Clear
For X = Year(Now)-100 to Year(Now)
> Combo1.AddItem CStr(X)
> Next
>
> Rick - MVP
--
Regards,
Michael Cole
| |
|
| Great, thanks a lot guys. I'm sorry for the little confusion. What Michael
assumed is exactly what I meant. When the customer information is filled in,
clerk will choose from a list of "Years", the year of birth. And as the years
go by, 1 year is dropped. I decided to keep 100 years in there, just in case.
=)
Thanks again....
"Michael Cole" wrote:
> Rick Rothstein wrote:
>
> Perhaps what he means is that as each year goes by, one year is dropped off
> and the next added.
>
> In which case, change the following line: -
>
>
> For X = Year(Now)-100 to Year(Now)
>
>
> --
> Regards,
>
> Michael Cole
>
>
>
| |
| argusy 2005-03-09, 4:02 pm |
| Can't see the point.
If the combobox list is from 1900 to 2000 (or 1906-2005 in 2005), then by the time you move the cursor to 1947 (when I
was born) and select it, it would be quicker to have typed "1947" into a text box!!
Even if you make it a drop-down box, you'd still be typing it in
(Even quicker - "47" and add a bit of code to pick up the century - after all, you're limiting it to 100 years)
And what if you DID have someone older than 100 years?
(Yeah, I know, ...... sigh .......... have another combobox)
Ummmm.... Just attracting arrows - don't take me too seriously :->
Argusy
Ricky wrote:
> Great, thanks a lot guys. I'm sorry for the little confusion. What Michael
> assumed is exactly what I meant. When the customer information is filled in,
> clerk will choose from a list of "Years", the year of birth. And as the years
> go by, 1 year is dropped. I decided to keep 100 years in there, just in case.
> =)
>
> Thanks again....
>
> "Michael Cole" wrote:
>
>
>
|
|
|
|
|