|
-
Apr 4th, 2008, 10:20 PM
#1
Thread Starter
Lively Member
[RESOLVED]_Last String.split value var[var[0]]
hi
I want the msgbox to display sample.ini. For this i need the last value of the splittted array. I know that in another language var[var[0]] would equal to final split, but it does not seem to work in vb. So what equals in vb to final array split?
vb Code:
Dim vArr As Object vArr = Split("C:\NetGame\Common\sample.ini", "\") MessageBox.Show(vArr(0))
Edit: Thanx.
Last edited by goldenix; Apr 5th, 2008 at 07:54 AM.

M.V.B. 2008 Express Edition
-
Apr 4th, 2008, 11:21 PM
#2
Re: Last String.split value var[var[0]]
Code:
Dim vArr() as String = "C:\NetGame\Common\sample.ini".Split("\"c)
MessageBox.Show(vArr(vArr.GetUpperBound(0)))
-
Apr 4th, 2008, 11:29 PM
#3
Fanatic Member
Re: Last String.split value var[var[0]]
This too work..
Code:
Dim sArr() As String = "C:\file\sample\sample.ini"
.Split("\".ToCharArray, StringSplitOptions.RemoveEmptyEntries)
Dim str As String = sArr(sArr.Length - 1)
MessageBox.Show(str)
Visual Studio.net 2010
If this post is useful, rate it

-
Apr 4th, 2008, 11:36 PM
#4
Re: Last String.split value var[var[0]]
If you want the file name from a path you shouldn't be using Split or String.Split:
vb.net Code:
Dim filePath As String = "C:\NetGame\Common\sample.ini" Dim folderPath As String = IO.Path.GetDirectoryName(filePath) Dim fileName As String = IO.Path.GetFileName(filePath) MessageBox.Show(folderPath) MessageBox.Show(fileName)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|