VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Strip a Single Word From a Text String

by Todd Wayman (8 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Wed 3rd January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Strip a Single Word From a Text String

Rate Strip a Single Word From a Text String




'* Start Comment Block  ***********************************
'* Generated using VB 3.0 ToolBar
'* Author: Todd Wayman
'* Date: Mar, 01, 2001
'* Version: 1.00
'* Function Title: StripWord
' *************************************************************
'* Comments:
'* This function was developed to pull individual words from
'* a text string.
'*
'* 
'*
'* StripWord returns the first word contained in the string.
'* sSrcString is the string to search
'* sFind is the separation character(s)
'*
'* Once sSrcString has been exhasted sSrcString returns "" and StripWord retruns the last occurance.
'*
'* An errror statement has been added.
'*
'* Note:
'*
'* sSrcString is modified by the function and returns the "" for trapping in loops.
'*
'* Example:
'*
'* Sub Command2_Click ()
'* Dim Temp, Temp2
'*
'* Temp2 = Text1.Text
'*
'* Text3.Text = ""
'*
'* Do Until Temp2 = ""
'*
'* Temp = StripWord(Temp2, Chr(13) & Chr(10))
'* Text3.Text = Text3.Text & DBAppMon1.TaskName(Val(Temp)) & Chr(13) & Chr(10)
'* Text3.Text = Text3.Text & DBAppMon1.TaskFileName(Val(Temp)) & Chr(13) & Chr(10)
'*
'* Loop
'*
'*
'* End Sub
'*
'* End Comment Block  *************************************


On Error GoTo Exit_Me:

If InStr(1, sSrcString, sFind) = 0 Then
StripWord = sSrcString
sSrcString = ""
Exit Function
End If

StripWord = Left$(sSrcString, InStr(1, sSrcString, sFind) - 1)
sSrcString = Mid$(sSrcString, InStr(1, sSrcString, sFind) + Len(sFind))

Exit Function
Exit_Me:
  StripWord = sSrcString
  sSrcString = ""
Exit Function


End Function


Download this snippet    Add to My Saved Code

Strip a Single Word From a Text String Comments

No comments have been posted about Strip a Single Word From a Text String. Why not be the first to post a comment about Strip a Single Word From a Text String.

Post your comment

Subject:
Message:
0/1000 characters