Search Tools Links Login

Vampsoft: Parse Text Function

Parses a Line of Text, Great for Chats...
Example Layout
String = "[Hello] [This] [is] [an] [Example] [Layout]"

Original Author: Lostsoul


Dim xText(10) As String
Dim total As Integer
Sub ParseText(Text As String)
Dim x As Integer
x = 0
For i = 1 To Len(Text) 'do Until i = the length of the string
  xText(x) = "" 'Make sure there is nothing in it already
  If Mid$(Text, i, 1) = "[" Then 'Check for a Start Bracket '['
    i = i + 1 'Add One to I so you don't get the Bracket
      xText(x) = xText(x) + Mid$(Text, i, 1) 'Added the leter at i in text to xtext at x
      i = i + 1 'NExt letter
    Loop Until Mid$(Text, i, 1) = "]" 'loop till you find a end bracket ']'
    x = x + 1 'Add 1 to x for the next element in xText
    total = total + 1 'keep track of total.
  End If
Next i
End Sub
Private Sub Form_Load()
total = 0
Call ParseText("[Word0] [Word1] [Word2] [Word3] [Word4] [Word5] [Word6]")
For i = 0 To total - 1
  MsgBox "xText(" & i & "): " & xText(i)
Next i

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 89 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.