by noyear (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 9th July 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
It is a parse function which can get a token from the string. It can use like that get_Token("Hellow World!"," "). If then, the output of this
'version 0.1.5
Dim c As String * 1
Dim L As Long
Dim i As Long
Dim j As Long
Dim dummy As String
Dim flag As Boolean
Dim word_cnt As Long
If Text = "" Then get_Token = "EOT": Exit Function
If theDivider = "" Then get_Token = "NO theDivider": Exit Function
word_cnt = 0
L = Len(Text)
flag = False
i = STart_POint - Direction
Do
i = i + Direction
c = Mid(Text, i, 1)
For j = 1 To Len(theDivider)
If c = Mid(theDivider, j, 1) Then
If dummy <> "" Then
If Order < 0 Then
Exit Do
Else
word_cnt = word_cnt + 1
If word_cnt = Order Then GoTo EXIT_DO
dummy = ""
flag = True
End If
Else
flag = True
End If
End If
Next
If Not flag Then
If Direction > 0 Then
dummy = dummy + c
Else
dummy = c + dummy
End If
Else
flag = False
End If
Loop Until (Direction > 0 And i >= L) Or (Direction < 0 And i = 1)
If dummy <> "" Then word_cnt = word_cnt + 1
EXIT_DO:
If Cut Then
If Direction > 0 Then
Text = Right(Text, L - i)
Else
Text = Left(Text, i - 1)
End If
End If
If i = L And dummy = "" Then
get_Token = "EOT"
Else
If Order > 0 Then
If word_cnt = Order Then
get_Token = dummy
Else
get_Token = "EOT"
End If
Else
get_Token = dummy
End If
End If
End Function
No comments have been posted about It is a parse function which can get a token from the string. It can use like that get_Token(Hello. Why not be the first to post a comment about It is a parse function which can get a token from the string. It can use like that get_Token(Hello.