2014-03-30 50 views
0

我想知道如何搜索兩個字符串,選擇它們之間的所有內容,然後將其複製到剪貼板。VB.NET搜索字符串並將其複製到剪貼板

Dim str As String 
    str = strcode 
    If str.Contains(".m3u8") = True Then 
     MsgBox("The string Contains() '.M3U8' ") 
    Else 
     MsgBox("The String does not Contains() '.M3U8'") 
    End If 

回答

0

使用此功能:

Function FindText(ByVal source As String, ByVal start As String, ByVal stop As String) 
    Dim startIndex As Integer = source.IndexOf(start) 
    If startIndex = -1 Then Throw New ArgumentException("start value not found in string") 
    startIndex += start.Length 

    Dim stopIndex As Integer = source.IndexOf(stop, startIndex) 
    If stopIndex = -1 Then Throw New ArgumentException("stop value not found in string") 

    Return source.SubString(startIndex, stopIndex - startIndex) 
End Function 

,並呼籲其結果ClipBoard.SetText()

+0

使代碼工作沒有錯誤,但我不知道它是如何工作的 – user3478897

相關問題