|
-
Oct 24th, 2013, 08:05 AM
#1
Re: Find text between two characters
Code:
Public Function GetBetween(ByRef sSearch As String, ByRef sStart As String, ByRef sStop As String, _
Optional ByRef lSearch As Long = 1) As String
lSearch = InStr(lSearch, sSearch, sStart)
If lSearch > 0 Then
lSearch = lSearch + Len(sStart)
Dim lTemp As Long
lTemp = InStr(lSearch, sSearch, sStop)
If lTemp > lSearch Then
GetBetween = Mid$(sSearch, lSearch, lTemp - lSearch)
End If
End If
End Function
'Usage:Text1.Text = Getbetween("123 get this 321","123","321")
-
Oct 24th, 2013, 08:58 AM
#2
Thread Starter
Junior Member
Re: Find text between two characters
 Originally Posted by Arnoutdv
Do you know the InStr method?
It will return the location of a substring in a string.
Yes i do, but I don't know wich tag will be used, I said <Name" just as an example... There are like 20+ tags, and I will not know wich one the user will use.
 Originally Posted by Bonnie West
Whenever you want to find a substring within a string, you use either the InStr or InStrRev functions. Both functions returns the character position where the substring was located.
So, what are you going to do once you've determined the position of those characters? Replace the text between them with something else? The Replace function can help you do that:
 Originally Posted by stum
[code]Public Function GetBetween(ByRef sSearch As String, ByRef sStart As String, ByRef sStop As String, _
But I'll not know wich tags has been used by the user...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|