Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding years go by..

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
Im trying to figure out the best way to add a year to a combo box every time the year advances one, I need to keep the old years as well..the oldest year will be this year.

Any ideas, although thats probably pretty confusing..?



 
dim yearArray(), numOfYears, startYear, i
startYear = 2002
numOfYears = startYear - Year(now()) + 1
redim yearArray(numOfYears)
for i = 0 to ubound(yearArray)-1
yearArray(i) = startYear + i
next
with response
.write(&quot;<select name=years><option value=none>SELECT ONE</option>&quot;)
for i = 0 to ubound(yearArray)-1
.write(&quot;<option value=&quot; & yearArray(i) & &quot;>&quot; & yearArray(i) & &quot;</option>&quot;)
next
.write(&quot;</select>&quot;)
end with

paul
penny1.gif
penny1.gif
 
I tried something like that...but I get a out of memory error on Redim YearAray
 
ReDim is one of the fattest little statements out there (resource wise) especially if you use preserve with it, but I haven't heard of it causing an error before.

eh... then do it w/o an array:

dim numOfYears, startYear, i
startYear = 2002
numOfYears = startYear - Year(now()) + 1
with response
.write(&quot;<select name=years><option value=none>SELECT ONE</option>&quot;)
for i = 0 to numOfYears-1
.write(&quot;<option value=&quot; & startYear+i & &quot;>&quot; & startYear+i & &quot;</option>&quot;)
next
.write(&quot;</select>&quot;)
end with
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top