Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

want to use split with no delimeter 1

Status
Not open for further replies.

imarosel

Technical User
Jun 23, 2005
149
US
I want to split a string that contains words and spaces and punctuation, but I want every character in the string to have its own place in the array. I tried putting in a zero length delimeter, but that didn't work.

txt1a = Split(txt1, "")
 
A string is kind of an array of characters, so there shouldn't be any need to split ...

[tt]dim s as string
dim lngCount as long
s = "this is some text"
for lngCount = 1 to len(s)
debug.print mid$(s, lngCount, 1)
next lngCount[/tt]

Roy-Vidar
 
ha, looking from the wrong perspective. Thanks.
 
But if you had to.

Public Function mySplit(strString As String) As String()
Dim counter As Integer
Dim intLength As Integer
intLength = Len(strString)
Dim tempArray() As String
ReDim tempArray(1 To intLength) As String
ReDim mySplit(1 To intLength)
For counter = 1 To intLength
tempArray(counter) = Mid(strString, counter, 1)
Next counter
mySplit = tempArray
End Function

Public Sub testSplit()
Dim tempArray() As String
tempArray = mySplit("xyzABC")
MsgBox tempArray(1)
MsgBox tempArray(6)
End Sub
 
A one-line way:
myArray = Split(StrConv(myText, vbUnicode), Chr(0))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top