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

concatenate 1

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
US
hello all,

this probably is one of the lamest question but I really stuck trying to display colors I assigned
Code:
bgcolor1 = "#0066CC"
bgcolor2 = "#009933"
bgcolor3 = "#FF0066"
bgcolor4 = "#FFCC00"
I tried to display the color by doing this
Code:
txtbg = "bgcolor"
rcount = 1
response.write "<font color='"&txtbg&rcount&"'>TESTING</font>"
but no luck... What is the deal here?

Thanks!
 
It doesn't work that way. You cannot concatenate to make a variable name. I recommend you use an array.

Code:
Redim bgcolor(3)

bgcolor(0) = "#0066CC"
bgcolor(1) = "#009933"
bgcolor(2) = "#FF0066"
bgcolor(3) = "#FFCC00"

response.write "<font color='" & bgcolor(rcount)  &"'>TESTING</font>"

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
thank you for the better way to solve my problem. I actually used Select Case to get the color by doing this
Code:
select case rcount
case 1
txtbg = bgcolor1
case 2
txtbg = bgcolor2
case 3
txtbg = bgcolor3
case 4
txtbg = bgcolor4
end select

It works, but yours is much simplier. Good work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top