Results 1 to 2 of 2

Thread: splitting text

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    I am making a game, and am trying to get it so any incoming data is done right..
    like in muds, but i dunno how to do it

    unless someone can tell me how they do it, this is what i would like to use:



    I would like to split some text

    example:
    hey guys what is up?

    Turns into these varaibles

    word1="hey"
    word2="guys"
    word3="what"
    word4="is up?"

    Soo, the first word is put into WORD1
    second into word2
    third into, word3
    and ANY WORDS after it go into word4

    If i could get this,, gREAT

    Lastly

    if it is possible

    i'd like it also to be able to do:
    Code:
          hey       guys what is         up?
    it turns out the same

    word1="hey"
    word2="guys"
    word3="what"
    word4="is up?"

    so, the first 3 words come out the same, but the words 4 and after, keep the spaces

  2. #2
    Lively Member iataman's Avatar
    Join Date
    Jun 2000
    Location
    Turkey
    Posts
    71

    Wink Text Handling

    Code:
    Dim Word(4), tmpText As String
    Dim i, LastSpace As Integer
    Dim MoreThanOneWord As Boolean
        
    MoreThanOneWord = True
    tmpText = TextToSplit
    
    For i = 1 To 3
         LastSpace = InStr(1, tmpText, " ")
         If LastSpace = 0 Then
              Word(i) = tmpText
              MoreThanOneWord = False
              Exit For
         Else
              Word(i) = Mid(tmpText, 1, LastSpace - 1)
              tmpText = Mid(tmpText, LastSpace + 1)
         End If
    Next
    
    If MoreThanOneWord Then Word(4) = tmpText
    MsgBox Word(1) + Chr(13) + Word(2) + Chr(13) + Word(3) + Chr(13) + Word(4)
    Hope It Helps..
    While YourAge<=40
    Live(YourLife)
    Wend

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