Advertisement
2002VB VB function enhancement #18097

SMid - "Smart" Mid

This function is similar to the Mid function. Except, you can specify the starting, and ending strings (capture the data in between).

AI

Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Zdrojový kód
original-source
'Example:
'newStr = SMid("Hello 1Between2 world!", 1, "1", "2")
'will return: "Between"

Function SMid(orig_string As String, start As Long, str_start As String, str_end As String)
On Error GoTo handler
'SMid (Smart MID)
'By: Derek de Oliveira
'Use this function in any program. No need to thank me :)
'o_string = Origional String
's_start = Start From string
's_end = Ending string
step1 = InStr(start, orig_string, str_start, vbTextCompare)
result = Mid(orig_string, step1 + Len(str_start), InStr(step1 + Len(str_start), orig_string, str_end, vbTextCompare) - step1 - Len(str_start))
SMid = result
Exit Function
handler:
SMid = ""
End Function
Původní komentáře (3)
Obnoveno z Wayback Machine