» Site Navigation | | | » Advertisement | | | » Recent Threads | | | | | | | | | Gay for Pay? 09-03-2009 02:30 PM Today 03:42 AM 27 Replies, 298 Views | |  |  | [VB.NET] GetBetween and GetBetweenAll |  |
10-07-2009, 05:35 AM
|
#1 (permalink)
| Banned
Join Date: Oct 2009 Posts: 172
GPoints: 1,892 Rep Power: 0 | [VB.NET] GetBetween and GetBetweenAll [VB.NET] GetBetween and GetBetweenAll GetBetween Code: Public Function GetBetween(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, _
Optional ByRef startPos As Integer = 0) As String
Dim iPos As Integer, iEnd As Integer, lenStart As Integer = strStart.Length
Dim strResult As String
strResult = String.Empty
iPos = strSource.IndexOf(strStart, startPos)
iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
If iPos <> -1 AndAlso iEnd <> -1 Then
strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
End If
Return strResult
End Function Getbetween parases a string between 2 strings in a source. GetBetweenAll Code: Public Function GBA(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, ByVal lstAdd As ListBox, Optional ByRef startPos As Integer = 0) As String
Dim iPos As Integer, iEnd As Integer, strResult As String, lenStart As Integer = strStart.Length
Do Until iPos = -1
strResult = String.Empty
iPos = strSource.IndexOf(strStart, startPos)
iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
If iPos <> -1 AndAlso iEnd <> -1 Then
strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
lstAdd.Items.Add(strResult)
startPos = iPos + lenStart
End If
Loop
GBA = ""
End Function Getbetweenall parses all the strings in the source that is between 2 strings.
Last edited by Backslash; 10-09-2009 at 06:00 PM..
| |
| | | The Following User Says Thank You to Backslash For This Useful Post: | |
10-10-2009, 04:37 PM
|
#2 (permalink)
| Underground
Join Date: Jul 2007 Location: Tallinn Age: 19 Posts: 298
GPoints: 3,469 Rep Power: 9 | There are many different variants of these functions going around, but nice job! 
__________________ "Reality is merely an illusion, albeit a very persistent one." | |
| |  | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |
| All times are GMT -7. The time now is 04:30 AM. | |