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

For Loop A-Z 2

Status
Not open for further replies.

lazytrucker

Programmer
Aug 4, 2004
39
0
0
GB

Just wondering if it is possible to carry out a loop from a-z in asp like you can in delphi.

Currently I use a script like this:

For iCol = 1 To 26
If iCol = 1 Then
sCol = "A"
ElseIf iCol = 2 Then
sCol = "B"
ElseIf iCol = 3 Then
sCol = "C"
.
.
.

.
ElseIf iCol = 26 Then
sCol = "Z"
End If

Statements

Next

Any ideas or more efficient alternatives appreciated.

Cheers LazyTrucker.
 
sure:
for i=65 to 95 'i dont the ascii code for Z
response.write chr(i)&"<br>"
next

Known is handfull, Unknown is worldfull
 
also if you'd rahter be lazy instead of looking up asci codes :

alphaset = array("a","b","c","d",.... etc)

for each letter in alphaset
whatever
next

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Cheers for the posts using Ascii run loop from 65 to 90.

 
Or:

For iCol = 1 To 26
sCol = Chr((icol - 1) + Asc("A"))
statements
Next
 
And just because this horse hasn't been ridden entirely into the ground:

Option Explicit
Dim i
For i = Asc("A") To Asc("Z")
WScript.Echo i & ")" & Chr(i)
Next

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
(He means Response.Write instead of WScript.Echo :))
 
Yeah. I sometimes forget which forum I'm in. What he said. [blush]

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top