Search_String 搜尋夾字
'''
''' Search_String 搜尋夾字
'''
''' 要搜尋的字串
''' 頭字串
''' 尾字串
''' 要查第幾個(不設傳回共幾個)
''' String(Integer)
'''
''' ex: Search_String("href='aaa' href='bbb' ", "href='", "'", 1))
''' return 'aaa'
''' ex: Search_String("href='aaa' href='bbb' ", "href='", "'"))
''' return 2
'''
Function Search_String(ByVal t1 As String, ByVal t2 As String, ByVal t3 As String, Optional v1 As Integer = 0)
Dim v As Integer
Dim String_len As Integer
For i = 1 To Len(t1)
If Mid(t1, i, Len(t2)) = t2 Then
String_len = 0
For j = i + Len(t2) To Len(t1)
String_len += 1
If Mid(t1, j, Len(t3)) = t3 Then
v += 1
If v1 <> 0 And v1 = v Then
Return Mid(t1, i + Len(t2), String_len – Len(t3))
End If
Exit For
End If
Next
End If
Next
Return v
End Function