-2

Another Small And Simple Function To Take Each Character of a string, and put it into an Array, This helps significantly when you need to sift through a string. This Function Uses The spush (String Push) Function, Also In Code Snippits.

Public Function str2Array(xString As String) As String()
Dim tmpArray() As String
Dim tmpchar As String

' /* For Each Character In The String */
For I = 1 To Len(xString)

    ' /* Retrieve The Character */
    tmpchar = Mid(xString, I, 1)
    ' /* Push It Into The Temporary Array */
    spush tmpArray, tmpchar
Next I

' /* Return The Array To The Calling Procedure */
str2Array = tmpArray
End Function
3
Contributors
3
Replies
5
Views
11 Years
Discussion Span
Last Post by jfc2k4
0

Couldn't you just do:

xString.ToCharArray

The only difference would be that you'd have a char array instead of a string array.

Alternatively, a better way in .net 2.0 would be to use the Array.ConvertAll method.

Regards,

Jan.

0

spush <---What's this? i tried the code in vb6 but it won't work. It says "not defined"

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.