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!

Arrays

Status
Not open for further replies.

uzzie123

Technical User
Mar 7, 2007
21
CA
Hi,

I want to create an array that will hold a fixed amount of character and the options will be presented in a drop down list when a user views it in the webpage.

Here is the code that I created so far:
"
Sub MapDriveSourceDD()
Dim Ret, i
Dim aDrives(6)

aDrives(0) ="T"
aDrives(1) ="U"
aDrives(2) ="V"
aDrives(3) ="W"
aDrives(4) ="X"
aDrives(5) ="Y"
aDrives(6) ="Z"
Ret = "<select name=""MapDriveSource"" id=""MapDriveSource"" class=""dropDownList"">"
Ret = Ret & "<option value='' checked>-none-"

For i = 0 to Ubound(aDrives)
Ret = Ret & "<option value='" & aDrives(i) & "'>" & aDrives(i)
Next

"

This code works fine. But I want to be more efficient with how I write my code. So i want to ger rid of the following code and put all of it in one line:

aDrives(0) ="T"
aDrives(1) ="U"
aDrives(2) ="V"
aDrives(3) ="W"
aDrives(4) ="X"
aDrives(5) ="Y"
aDrives(6) ="Z"

I tried: " aDrives(i) = ("T", "U" .....) ", but it does not work. Can anyone tell me a more efficient way to write the above code?

Thx




 
You can use the escape characters to do this.
&#84; is the code for T
loop and add 1 to the code each time:

Code:
    For i = 0 to 6
       Ret = Ret & "<option value='&#" & (i + 84) & ";'>&#" & (i + 84) & ";</option>";
    Next

*disclaimer: I come from a Javascript background, so syntax may not be 100%, but the idea is :)

[monkey][snake] <.
 
No problem, ask if you have any problems with this. I'll lookup the syntax if need be.

[monkey][snake] <.
 
Alternatively...

Code:
aDrives = Array("T", "U", "V", "W", "X", "Y", "Z")



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Ye, I figured that second part out :). I just have one other quick question.

Now i created an array with a list of characters (T, U...). I want to create another array that displays the same characters minus the one character that was selected from the first array. How can I achieve this?

My second array is called "size"

Thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top