Results 1 to 4 of 4

Thread: separating the word

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Posts
    26

    separating the word

    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

  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    VB Code:
    1. Dim x() As String
    2. Dim strData As String
    3.  
    4. Private Sub Command1_Click()
    5. strData = "book"
    6. i = Len(strData)
    7. ReDim x(i)
    8. For y = 1 To Len(strData)
    9.     x(y) = Mid(strData, y, 1)
    10.     Print x(y)
    11. Next
    12. End Sub
    <removed by admin>

  3. #3
    An array.
    VB Code:
    1. Const s As String = "book"
    2.  
    3. Dim Letters() As String
    4. ReDim Letters(0 To Len(s))
    5.  
    6. Dim i As Integer
    7. For i = 0 To Len(s)
    8.     Letters(i) = Mid$(s, i, 1)
    9. Next i

  4. #4
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    I'm in front of the computer.
    Posts
    270
    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.
    Alphanos

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width