-
what is a good way to split a string variable into
several other variables, or seperate lines by number of characters?
Thanks
[email protected]
In the near future the common person will think that Microsoft developed the first operating system, and invented the internet in collaboration with Al Gore.
-
<?>
[code]
Split
Returns a zero-based, one-dimensional array containing a specified number of substrings.
Syntax
Split(expression[, delimiter[, count[, compare]]])
The Split syntax has these parts:
Part Description
expression Required. String expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data.
delimiter Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
count Optional. Number of substrings to be returned; -1 indicates that all substrings are returned.
compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values.
Settings
The compare argument can have the following values:
Constant Value Description
vbBinaryCompare 0 Perform a binary comparison.
vbTextCompare 1 Perform a textual comparison.
vbDatabaseCompare 2 Perform a comparison based on information contained in the database where the comparison is to be performed.
[/ode]
-
Use the Split() function
Code:
Dim MyString As String
MyString = "One,Two,Three,Four,Five"
'Split whenever there is a comma
MyArray = Split(MyString, ",")
'Display each element
For I = LBound(MyArray) To UBound(MyArray)
Print MyArray(I)
Next I
-
call me crazy
so if I had a variable [penguin] and
penguin = "even if the attacker cannnot read the contents of your encrypted messages, he may be able to infer at least some useful information."
then I could
Split (penguin, Char(13), 25)
(trying to split it every 25 characters with a carriage return)
-
You would have to do it this way then:
Code:
dim n as integer,temp as string
For n=1 to len(penguin) step 25
if n>1 then temp=temp & vbcrlf
temp=temp & mid(penguin,n,25)
next n
penguin=temp