PDA

View Full Version : [VB6] Fast GetStringBetween



j03
12-28-2011, 11:20 AM
Fastest? Well I'd like to say it is as some people claim it to be, but anything is possible

Here it is:



Public Function GetStringBetween(Main As String, start As String, Finish As String, Optional Index As Long = 1) As String
On Error Resume Next
GetStringBetween = Split(Split(Main, start, Index + 1)(Index), Finish, 2)(0)
End Function


An example of using this to grab NP on hand would be:

lblNP.Caption = GetStringBetween(HTML, "NP: <a id='npanchor' href=""/objects.phtml?type=inventory ([Only registered and activated users can see links])"">", "</a>")

PS: If you have to use quotation marks in your code, put two like how I did. Otherwise it not work.

Zachafer
03-11-2012, 12:43 PM
Joe I'm pretty sure using Mid$ (even better MidB$) is faster than using Split, especially because the Delimiter parameter is a variant and variants are the slowest data types.