i have a word at a string:
x = "book"
and i want to do this:
x1 = "b"
x2 = "o"
x3 = "o"
x4 = "k"
but the string changes and I don't know to do this because one time is 4 letters but other time is 5 letters.
any help??
thank's
Printable View
i have a word at a string:
x = "book"
and i want to do this:
x1 = "b"
x2 = "o"
x3 = "o"
x4 = "k"
but the string changes and I don't know to do this because one time is 4 letters but other time is 5 letters.
any help??
thank's
VB Code:
Dim x() As String Dim strData As String Private Sub Command1_Click() strData = "book" i = Len(strData) ReDim x(i) For y = 1 To Len(strData) x(y) = Mid(strData, y, 1) Print x(y) Next End Sub
An array.
VB Code:
Const s As String = "book" Dim Letters() As String ReDim Letters(0 To Len(s)) Dim i As Integer For i = 0 To Len(s) Letters(i) = Mid$(s, i, 1) Next i
A slightly different approach you could use that might be a bit faster, but less convienient, it to use StrConv to make a byte array of the ascii codes of the characters. You'd have to use Chr$ on each letter then though.
IE
Dim Bytes() as Byte
Bytes() = StrConv(Text, vbFromUnicode)
would give you an array called bytes containing the ascii codes of each character.