2016-02-27 74 views
1

我有字符串:如何從背後砍字符串時命中/ vb.net

Dim Location As String = "D:/Temp/Stats.pdf"

,我想削減一切由右至左時,我打「/」 輸出應該是:

Stats.pdf

我試圖Sub.stringtrimm,但沒有運氣,是它甚至可能從behinde削減?

預先感謝您

回答

1

考慮使用String.SplitString().Last()

Dim Location As String = "D:/Temp/Stats.pdf" 
Dim Strs As String() = Location.Split("/") 
Dim FileName As String = Strs.Last() 

你的結果是在用於其他用途的情況下另一個代碼的FileName

+0

非常感謝很多,這很容易,我對自己很生氣...... :( – LazaBre

+0

@LazaBre不,不,請放輕鬆。 :)一次只學一件事,好嗎? – Ian

+0

Ofc,謝謝你,我正在用自己的在線教程學習vb.net語言..:P它不容易像人們說..:P再次感謝你 – LazaBre

2

您可能感興趣的:

Public Class Form1 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    Dim sLocation As String = "D:/Temp/Stats.pdf" 
    Dim directoryPath As String = System.IO.Path.GetDirectoryName(sLocation) 
    Dim FileName As String = System.IO.Path.GetFileName(sLocation) 
    MessageBox.Show(directoryPath) 
    MessageBox.Show(FileName) 
    End Sub 
End Class