Arrays

1. Senior Member
Join Date
Dec 1969
Posts
130

## Arrays

I have an integer like 123456. I want to split that into an array like ("1","2","3", etc.,). We can use split function for strings. but i don&#039;t know how to use split function for integers. Can anybody help me please.

2. Senior Member
Join Date
Dec 1969
Posts
16,931

...CStr(123456) - then you have a string....<BR><BR>Craig.

3. Senior Member
Join Date
Dec 1969
Posts
130

Thanks for your response. But the problem is, we can split the strings by &#039;,&#039; or &#039; &#039;. But for integers there is not &#039;,&#039; or &#039; &#039; between them. <BR><BR>There is round about for that. We can add a &#039;,&#039; after every character in the integer after that we can use the split function. But i am looking for a funtion like split, if any exists.

4. Senior Member
Join Date
Dec 1969
Posts
16,931

## Come on, is it hard?!

&#060;%<BR>Function SplitStringByChar(strStringToSplit)<BR> Dim intCounter, tempArray<BR> For intCounter = 1 to Len(strStringToSplit)-1<BR> if IsArray(tempArray) = True then<BR> ReDim Preserve tempArray(UBound(tempArray))<BR> else<BR> ReDim Preserve tempArray(0)<BR> end if<BR> tempArray(UBound(tempArray)) = Mid(strStringToSplit, intCounter, 1)<BR> Next<BR> SplitStringByChar = tempArray<BR>End Function<BR>%&#062;<BR><BR>Ok, you might have to muck about with it a little, but it&#039;s 90% there... Was that really hard? It&#039;s just very basic string manipulation.<BR><BR>Craig.

5. Senior Member
Join Date
Dec 1969
Posts
102

AFAIK there&#039;s nothing that comes with ASP to do this, so here&#039;s something which took me about 30 seconds to write :<BR><BR>&#060;%<BR>num = 123456789<BR><BR>function MySplit(ByVal n)<BR>dim i,a<BR><BR> redim a(len(n)-1)<BR> for i = 0 to ubound(a)<BR> a(i) = mid(n,i+1,1)<BR> next<BR> <BR> MySplit = a<BR> <BR>end function<BR><BR>arry = MySplit(num)<BR><BR>for i = 0 to ubound(arry)<BR> response.write arry(i)<BR>next<BR>%&#062;<BR><BR><BR>--<BR><BR>AS

6. Senior Member
Join Date
Dec 1969
Posts
130

## RE: Come on, is it hard?!

Thank you Craig. You are a gem.

7. Senior Member
Join Date
Dec 1969
Posts
130