SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Join function to add all elements of an array to create string variable in ASP

We can create a string by joining all the elements of an array by using join() function. The out put of this function is a string variable. Here is the syntax of using join() function.
My_String = join(My_Array)

Here My_Array is the array and the My_String is the string variable which gets the string which is returned by join function after adding all the elements of the My_Array array.

While joining by default one blank space is used as delimiter, we can specify any delimiter while joining the elements by using join function. Here is the syntax of this.
my_String=join(myArray,",")

This way we can have any delimiter added between the elements while generating the string variable. In the above example comma ( , ) is used.

Here is the complete code for joining elements and creating a string variable.

Dim myArray(3) 'Declaring a dynamic array

myArray(0) = "UK"
myArray(1)="USA"
myArray(2)="Canada"
myArray(3)="UAE"

For Each item In myArray
Response.Write(item & "<br>")
Next

my_String=join(myArray,",")
Response.Write(my_String & "<br>")


Same way we can create array by breaking string using split function

Further readings
Declaring Fixed and Dynamic size array in ASP
Getting size of an array
Creating arrays by splitting string using split() function
Joining elements of an array to create a string variable
Searching inside array elements for matching string using Filter
 
Scripts
PHP
JavaScript
All ASP Tutorials
Popular Tutorials
Managing two drop downs
ASP Tutorials
Date and time
Declaring array
Form in ASP
Server.MapPath
Date Time & MSSQL
Select Query
File System Object
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.