String To Array


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.

About the Author

Die Monster! You don't belong in this world!

It was not by my hand, that I am once again given flesh. I was called
here by humans, who wish to pay me tribute!

TRIBUTE! You steal men's souls and make them your slaves!

Perhaps the same could be said of all religions....

Your words are as empty as your soul. Mankind ill needs a savior such as you!

What is a man?
*Throws A Wine-Filled Goblet*
A miserable little pile of secrets! But enough talk!
Have at you!

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
wilsonjan 0 Unverified User

Couldn't you just do:


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.



wilsonjan 0 Unverified User

Apologies, I was being a bit dim and thought this group included .net


jfc2k4 0 Newbie Poster

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.