■ 문자열을 추출하는 방법을 보여준다.
▶ 문자열 추출하기 예제 (VB)
1 2 3 |
Print ExtractString("[ID] id1 [Password] password1", "[ID]", "[") |
▶ 문자열 추출하기 (VB)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
' 문자열 추출하기 ' strSource : 소스 문자열 ' strSearch1 : 검색 문자열 1 ' strSearch2 : 검색 문자열 2 Public Function ExtractString(strSource As String, strSearch1 As String, strSearch2 As String) Dim nSearch1 As Integer Dim nSearch2 As Integer If Not InStr(1, strSource, strSearch1) = 0 Then nSearch1 = InStr(1, strSource, strSearch1) + Len(strSearch1) nSearch2 = InStr(nSearch1, strSource, strSearch2) ExtractString = Mid(strSource, nSearch1, nSearch2 - nSearch1) Else ExtractString = "" End If End Function |