|
-
Nov 20th, 2006, 03:46 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Delete string split symbol
Hello,
I have the following string in Cooridnates:
(0,0,11,11)#(1,1,22,334)#(34,54,55,66)
With the following code I delete the last coordinates:
VB Code:
strCoordinates = Coordinates.Split("#")
strCoordinates(counter) = ""
Coordinates = Join(strCoordinates, "#")
TextBox1.Text = Coordinates
The coordinates now look like this:
(0,0,11,11)#(1,1,22,334)#
However they should look like this:
(0,0,11,11)#(1,1,22,334)
How do I get rid of the LAST "#"???
Thanks in advance guys
-
Nov 20th, 2006, 04:08 AM
#2
Re: Delete string split symbol
Don't use Split at all.
VB Code:
Dim myString As String = "(0,0,11,11)#(1,1,22,334)#(34,54,55,66)"
myString = myString.Substring(0, myString.LastIndexOf("#"c))
Note that if the string doesn't contain that character that code will throw an exception, so if you aren't already sure then you need to test it.
-
Nov 20th, 2006, 05:14 AM
#3
Thread Starter
Fanatic Member
Re: Delete string split symbol
Thank you very very much,
That works perfect.
But now were still on the subject of strings .
Like you said I have to check for the "#" value in my string or otherwise I get an error message.
I tried the following:
VB Code:
If Coordinates Like "*#*" Then
Coordinates = Coordinates.Substring(0, Coordinates.LastIndexOf("#"c))
Else
Coordinates = ""
End If
But I still get the error message...
-
Nov 20th, 2006, 05:36 AM
#4
Re: Delete string split symbol
VB Code:
Dim myString As String = "Hello#"
If myString.Contains("#") Then
'Do stuff
End If
-
Nov 20th, 2006, 05:52 AM
#5
Thread Starter
Fanatic Member
Re: Delete string split symbol
Thank you very very much for all your help guys...
Everything works perfect...
CU Next time...
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
|