Desert Ghost - - Color Table - VBS

# Thread: Desert Ghost - - Color Table - VBS

1. Senior Member
Join Date
Dec 1969
Posts
2,049

## Desert Ghost - - Color Table - VBS

&#060;%<BR>Response.Write "&#060;table&#062;"<BR><BR>Dim i<BR>Dim n<BR>Dim h,Clr,Color,rgb<BR>Clr = Array( "00","33","66","99","CC","FF" ) <BR>For i = 0 To 5 <BR>Response.Write "&#060;tr&#062;"<BR><BR>For Stp = 0 To 2<BR>For Each h In Clr<BR> <BR>If Stp = 0 Then<BR>rgb = Cint(i)<BR>Color = "00" & h & Clr(rgb)<BR>End If<BR><BR>If Stp = 1 Then<BR>rgb = Cint(i)<BR>Color = "33" & h & Clr(rgb)<BR>End If<BR><BR>If Stp = 2 Then<BR>rgb = Cint(i)<BR>Color = "66" & h & Clr(rgb)<BR>End If<BR><BR>Response.Write "&#060;td width=20 height=20 bgcolor=&#039;#"& Color &"&#039;&#062;&nbsp;"<BR>Next<BR>Next<BR><BR>Respo nse.Write "&#060;/tr&#062;"<BR>Next <BR><BR><BR>For i = 0 To 5 <BR>Response.Write "&#060;tr&#062;"<BR><BR>For Stp = 0 To 2<BR>For Each h In Clr<BR> <BR>If Stp = 0 Then<BR>rgb = Cint(i)<BR>Color = "99" & h & Clr(rgb)<BR>End If<BR><BR>If Stp = 1 Then<BR>rgb = Cint(i)<BR>Color = "CC" & h & Clr(rgb)<BR>End If<BR><BR>If Stp = 2 Then<BR>rgb = Cint(i)<BR>Color = "FF" & h & Clr(rgb)<BR>End If<BR><BR>Response.Write "&#060;td width=20 height=20 bgcolor=&#039;#"& Color &"&#039;&#062;&nbsp;"<BR>Next<BR>Next<BR><BR>Respo nse.Write "&#060;/tr&#062;"<BR>Next <BR><BR><BR><BR><BR>Response.Write "&#060;/table&#062;"<BR>%&#062;<BR><BR>I figured you would not look at you thread anymore.

2. Senior Member
Join Date
Dec 1969
Posts
11,334

## Oh yeah, Thanks jon

I don&#039;t have IIS running where I&#039;m at, so I can&#039;t test it out... I will tomorrow though.<BR><BR>I&#039;m pretty sure this will have to be in a distributed .exe though -- but I&#039;ve learned something new today, and somebody else may be able to benefit from your code as well.<BR><BR>Thanks again for your input!

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## See post below...

I don&#039;t understand why this code sometimes use FOR I=0 TO 5, sometimes uses FOR EACH, and sometimes just wings it with hard coded strings.<BR><BR>Especially the hard coded strings.<BR><BR>Even if you wanted to write this as a pair of master loops instead of pulling my trick, why not at least drastically simplify the code?<BR><BR>Clr = Array( "00","33","66","99","CC","FF" ) <BR>For Each r in Clr<BR>&nbsp; &nbsp; Response.Write "&#060;tr&#062;"<BR>&nbsp; &nbsp; For g = 0 To 2<BR>&nbsp; &nbsp; &nbsp; &nbsp; For Each b In Clr<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; color = r & clr(g) & b<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write "&#060;td width=20 height=20 bgcolor=&#039;#"& Color &"&#039;&#062; "<BR>&nbsp; &nbsp; &nbsp; &nbsp; Next<BR>&nbsp; &nbsp; Next<BR>&nbsp; &nbsp; Response.Write "&#060;/tr&#062;"<BR>Next <BR>For Each r in Clr<BR>&nbsp; &nbsp; Response.Write "&#060;tr&#062;"<BR>&nbsp; &nbsp; For g = 3 to 5<BR>&nbsp; &nbsp; &nbsp; &nbsp; For Each b In Clr<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; color = r & clr(g) & b<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write "&#060;td width=20 height=20 bgcolor=&#039;#"& Color &"&#039;&#062; "<BR>&nbsp; &nbsp; &nbsp; &nbsp; Next<BR>&nbsp; &nbsp; Next<BR>&nbsp; &nbsp; Response.Write "&#060;/tr&#062;"<BR>Next <BR><BR>Ehhh...I still don&#039;t like mixing the FOR EACH and the FOR g, but what the heck.<BR><BR>Hopefully, by "unrolling" the loops this way you can see how my "gs" ("green start") trick works in the code below.<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
2,049

## RE: See post below...

The color results are different between the two...<BR><BR>I do see how you simplified it. (you are good at that)<BR>And yes, I did take your idea and run with it. ;p<BR><BR>I will take a closer look at your code below.<BR><BR>Have you double checked to make sure the the colors are web safe?(curious)<BR>I went by Ultra Devs web pallete to get the pattern.

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## Do a VIEW | SOURCE...

...of the HTML generated by your code and compare it to that generated by mine.<BR><BR>I just misread your code and got the rgb values in the wrong order. Every color in your chart is in mine and vice versa.<BR><BR>Easy to change to match yours exactly. Instead of<BR>&nbsp; &nbsp; &nbsp; color = r & clr(g) & b <BR>Do<BR>&nbsp; &nbsp; &nbsp; color = clr(g) & b & r<BR><BR>Or, in my other post, do:<BR>&nbsp; &nbsp; &nbsp; rgbc = clr(g) & clr(b) & clr(r)<BR><BR>It doesn&#039;t really matter what order you put those in. The important point is to cycle through all 216 possible values, that&#039;s all.<BR><BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•