Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Here's what I have. The selected text in a FileListBox is Detail.wmf. I'm trying to get strTrimmed to equal Detail without the .wmf. The trim never happens. No errors.... What am I doing wrong?

 

       Dim strTrimmed As String = Me.FileListBox.Text.TrimEnd(".wmf")

 

thanks,

Bernie

  • Administrators
Posted

http://msdn2.microsoft.com/en-us/library/system.string.trimend.aspx would be worth a read as it explains what .TrimEnd does. If you want to remove the .wmf from the string you could either use something like

 

Dim strTrimmed As String = Me.FileListBox.Text.Substring(0, s.Length - 4)

 

or even better use the Path class to do the work for you.

Dim strTrimmed As String = System.IO.Path.GetFileNameWithoutExtension(Me.FileListBox.Text)

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

I really like example #2. Thanks. Works great!

 

http://msdn2.microsoft.com/en-us/library/system.string.trimend.aspx would be worth a read as it explains what .TrimEnd does. If you want to remove the .wmf from the string you could either use something like

 

Dim strTrimmed As String = Me.FileListBox.Text.Substring(0, s.Length - 4)

 

or even better use the Path class to do the work for you.

Dim strTrimmed As String = System.IO.Path.GetFileNameWithoutExtension(Me.FileListBox.Text)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...