Turn string into an array of characters

wrek

Registered User.
Local time
Today, 05:37
Joined
Jun 14, 2001
Messages
88
S'been so long since i've been involved in any semblance of coding, its almost embarrassing. Potentially easy one:

I need to pass a string (input from a form's textbox) into an array of characters (dimension = the size of the string), for some string handling on a character by character basis.

Any quick snippet of code someone can direct me to?

Thanks,
 
dont think there is any thing built in but this should do it.
Function AString(strIn As String) As Variant
Dim j As Integer
Dim aStrIn() As String
ReDim aStrIn(Len(strIn) - 1)
For j = 0 To Len(strIn) - 1
aStrIn(j) = Mid(strIn, j + 1, 1)
Next j
AString = aStrIn
End Function

Peter
 
Peter,

Smashingly efficient. Thanks. :D
 
Since you have to loop through the string character by character, what is the point of creating an array which you will then have to loop through entry by entry? Can't you just do what you want on the first pass?
 

Users who are viewing this thread

Back
Top Bottom