Private Shared Function SearchMidString(ByVal s As String, ByVal s1 As String, ByVal s2 As String) As String '获取搜索到的数目 Dim n1 As Integer, n2 As Integer n1 = s.IndexOf(s1, 0) + s1.Length '开始位置 n2 = s.IndexOf(s2, n1) '结束位置 Return s.Substring(n1, n2 - n1) '取搜索的条数,用结束的位置-开始的位置,并返回 End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'MsgBox(GetFileName("/dir1001/aaa.txt")) MsgBox(SearchMidString("/dir1001/ghghjghj/aaa.txt", "/", "/")) End Sub |
转载请注明:vs2010» 截取两个字符中间的字符串
标签: