View Full Version : Insert text from variable into an array
02-11-2003, 08:11 AM
How can I possibly divide up text into an array or similar?
Into an array?
The text is in a variable already but I need to split it up into an array like I said.
I'm getting this text from a python proggy, I can present the text in any way I like so if you think it would be better to have some character signifying the start and end of the line I can do that.
02-11-2003, 10:26 AM
I'm having such a bad day, I'd forget my head if it weren't screwed on. (not literally of course!;))
02-13-2003, 02:27 AM
Hehe, I use split all the time... usually what I do is concatenate a string like:
If so and so
stringname = stringname & variable & "|"
usually in a loop instead, so you end up with stuff like:
Then I just trim off the last pipe:
If Len(stringname) > 0 Then
stringname = Left(stringname,Len(stringname-1))
stringarray = Split(stringname,"|")
For iCount = 0 to UBound(stringarray)
' Do Something
Of course if you already have your string delimited by something then you can just split it up by that character or combination of characters.
For instance, check out this function, it will change a comma-delimited string with a double-quote text identifier into a pipe-delimited string:
mystring = """rob"",""blah"""
Function Comma2Pipe(byVal str)
If IsNull(str) Then Exit Function
Comma2Pipe = Replace(Replace(str,""",""","|"),chr(34),"")
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.