VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Extracts segments in a string seperated by spaces.

by Emporer (4 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 9th November 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Extracts segments in a string seperated by spaces.

API Declarations



Text = The String
Segment = Segment to be extracted
ExNextStart = A Variable that will be the next starting point in the string

Rate Extracts segments in a string seperated by spaces.



Public Function Extract(Text As String, Segment As Integer, Optional ExNextStart As Variant)
 Dim a(1 To 10) As String
 st = 1
 For x = 1 To 10
  i = 0
  Do
    DoEvents
    i = i + 1
    a(x) = Mid(Text, st, i)
    If (i > 50) Then ExNextStart = Len(Text) + 1: Exit Do
    If (Len(a(x)) = Len(Text)) And (x = Segment) Then ab = a(x): ExNextStart = Len(Text) + 1: Exit Do
  Loop Until (Right(a(x), 1) = " ")
  If (ab <> "") Then Exit For
  a(x) = Trim(a(x))
  st = st + i
  ExNextStart = st
  If (x = Segment) Then Extract = a(x): Exit Function
  DoEvents
 Next x
 Extract = ab
End Function


Download this snippet    Add to My Saved Code

Extracts segments in a string seperated by spaces. Comments

No comments have been posted about Extracts segments in a string seperated by spaces.. Why not be the first to post a comment about Extracts segments in a string seperated by spaces..

Post your comment

Subject:
Message:
0/1000 characters