post your comment   print   send to a friend
Rate:   0% | Views: 694
Question categories:  ASP

How can I display all of the contents of a single-dimension array?

There are a number of ways you can display the contents of a single-dimension array. Use a 'For ... Next' loop to iterate through each element in the array. You can find the lower and upper bounds of an array by using the LBound and UBound functions, respectively.

The following snippet of code displays each element of the array aFoo using a 'For ... Next' loop

'Create the aFoo array
Dim aFoo
aFoo = Array("Hello", "Aplus!", "How ", "are ", "you?"

Dim iLoop
For iLoop = LBound(aFoo) to UBound(aFoo)
Response.Write aFoo(iLoop) & "<BR>"
Next

The above code will produce the following output (when viewed through a browser)

Hello
Aplus!
How
are
you?


There is another way to display the contents of a single-dimension array. VBScript provides a join function that converts the contents of an array into a string using a specified delimiter between each element of the array in the string. To display each element of an array, followed by a <BR>, use the following code:

'Create the aFoo array
Dim aFoo
aFoo = Array("Hello", "Aplus!", "How ", "are ", "you?"

Response.Write join(aFoo, "<BR>")

This code will produce the exact same output as the code snippet we first examined, but it requires less code.

Customer Feedback
Rate:   0% | Views: 694 | Please Rate:  
 
If you have other comments or ideas for future technical tips, please type them here:

Email: (optional)

Comments: (optional)

 Domains Registration | Domain Names Registration    Back to serch results
Browse the Base
Knowledge Base
Web Design
  Do It Yourself
    ASP
Messages
 

Blogging at Aplus.Net

Don't forget to check out our blog ! Keep up to date at Aplus.Net.

Private Area
 
Ask
in Private
   
Personal
Folder
 
Related Questions
 
1. Does ASP.Net still recognize the global.asa file?
 
2. Is it possible to run client-side .NET code within a browser?
 
3. What happened to date() and time()?
 
4. How do I display data on a web page using arrays instead of Do...While...MoveNext...???
 
5. How do I extract the contents of an array without knowing the size of the array?
 
Home Browse Search Ask in Private Personal Folder   Help
powered by web hosting 
  Logged as: Guest