A anin Member Joined Feb 21, 2005 Messages 10 Programming Experience 1-3 Apr 7, 2005 #1 [Resolved] String manipulation Cud someone please tell me how to truncate the String "TESTFILE.XML" to "TESTFILE" I want to remove the .xml from the string. thanks, Last edited: Apr 7, 2005
[Resolved] String manipulation Cud someone please tell me how to truncate the String "TESTFILE.XML" to "TESTFILE" I want to remove the .xml from the string. thanks,
A anin Member Joined Feb 21, 2005 Messages 10 Programming Experience 1-3 Apr 7, 2005 #2 ok... String.replace(".xml","") works. Upvote 0 Downvote
L levyuk Well-known member Joined Jun 7, 2004 Messages 313 Location Wales, UK Programming Experience 3-5 Apr 7, 2005 #3 Dim s As String = "TESTFILE.XML" MessageBox.Show(s.Remove(8, 4)) Upvote 0 Downvote
A anin Member Joined Feb 21, 2005 Messages 10 Programming Experience 1-3 Apr 7, 2005 #4 The String could be anything and I wanna do it at runtime. Upvote 0 Downvote
JuggaloBrotha VB.NET Forum Moderator Staff member Joined Jun 3, 2004 Messages 4,530 Location Lansing, MI; USA Programming Experience 10+ Apr 8, 2005 #5 levyuk said: Dim s AsString = "TESTFILE.XML" MessageBox.Show(s.Remove(8, 4)) Click to expand... that works, but also limits to the length of the name.ext String.replace(".xml","") allows for a variable lenth name.ext Upvote 0 Downvote
levyuk said: Dim s AsString = "TESTFILE.XML" MessageBox.Show(s.Remove(8, 4)) Click to expand... that works, but also limits to the length of the name.ext String.replace(".xml","") allows for a variable lenth name.ext
Paszt Staff member Joined Jun 3, 2004 Messages 1,500 Location Raleigh, NC - USA Programming Experience Beginner Apr 10, 2005 #6 The code given above is perfectly viable. Another alternative (always good to have alternatives) is: VB.NET: Dim strFileName As String = _ System.IO.Path.GetFileNameWithoutExtension("TESTFILE.XML") Upvote 0 Downvote
The code given above is perfectly viable. Another alternative (always good to have alternatives) is: VB.NET: Dim strFileName As String = _ System.IO.Path.GetFileNameWithoutExtension("TESTFILE.XML")
A anin Member Joined Feb 21, 2005 Messages 10 Programming Experience 1-3 Apr 11, 2005 #7 Great and a better alternative. Thanks. Upvote 0 Downvote