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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assigining to variable in a loop 1

Status
Not open for further replies.

crazyboybert

Programmer
Jun 27, 2001
798
GB
Hi Guys,

I want to assign vaues to consecutively numbered variables using a for loop. the code i have a t the moment is
Code:
for count = 1 to 10
if eval("dob" & count) = "" then
"dob" & count = "n/a"
end if
next

i have ten variables dim dob1 to dob10. they may or may not have a value. if they dont i wish to set them to "n/a". I tried using eval() as you would in javascript but this didnt work. If i run the code as it is above i get an expected statement error on the line

"dob" & count = "n/a"

any help with this greatly appreciated

cheers

rob
 
why don't you store your dob values in an array? ie:

dim dob(9)

for count = 0 to 9
if eval("dob" & count & "") = "" then
dob(count) = "n/a"
end if
next


and i believe you need the & "" after count in your field name (eval("dob" & count &""))
 
cheers lobstah,

know when you cant see the wood for the trees. I guess my grey matter is still out there with the new year fairies!! still first day back so plenty of time for improvement. Thanx for nudging the cogs back into line

X-)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top