餘長可變,其中包含以下信息vb.net,分離分隔變量爲數組元素中VB.NET
Dim g As String = "$C:\Program Files\Cavaj Java Decompiler\cavaj.exe$C:\Users\Yoosuf\AppData\Local\Google\Chrome\Application\chrome.exe$C:\Program Files\DVD Maker\dvdmaker.exe$C:\Program Files\Adobe\Adobe Photoshop CS2\ImageReady.exe$C:\Program Files\Java\jre6\bin\javaws.exe$"
的$
符號被用作分隔符的每個項目與其它分離。我需要將每個路徑末尾的exe文件名添加到列表框中。然而,將變量檢索到單個數組元素的初始過程無法正常工作。
Dim strArr() As String = g.Split("$") 'This variable is empty
For count = 0 To strArr.Length - 1
Dim arr As String = strArr(count).Split("\")
Dim strval As String = ""
For i As Integer = 3 To arr.Length - 1
strval = arr(i)
Dim j As Integer = arr.Length - 1
strval = arr(j)
Dim result As String = strval.Substring(g.Length - 5)
result = g.Substring(g.LastIndexOf("\") + 1)
ListBox1.Items.Add(result)
Next
Next
適合我。 strArr.Length = 7.我看不到你的代碼有任何問題 – barrylloyd 2012-03-05 04:31:27