Visual Studio Development Bookmark and Share   
 index > Visual Basic Express Edition > remove a different amount of letters from a string
 

remove a different amount of letters from a string

Hi I want to remove the info from a text box so i can auto fill the artist and track info from the selected file
the textbox has some thing like "D:\Music\Video\2008-1\Lonely Island, The Ft. TPain-I'm On A Boat.mpg"
But the length of the tracks and artist change and the folders are different as well the only thing thing the same is the format artist-title.mpg can some one help me??

    Private Sub name_up_date_info()

        Dim str1 As String = Textbox1.Text
        Dim str2 As String = Textbox1.Text
        If str1.Contains("-") Then
            Dim myChar As Char() = {"m"c, "p"c, "g"c, "."c}
            Dim NewString As String = str1.TrimEnd(myChar)

            Dim myString As String = str1
           
            MsgBox(NewString)

            txtArtist.Text = str1
            txtTrackTit.Text = str2
      
        Else
     
        End If
    End Sub

I am just learning and only 14 so sorry for question that are simple :)
BckSpc  Sunday, October 18, 2009 10:55 PM
I'm not sure where the artist and title separate (is it at the comma?), but you can do this


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim line As String = "D:\Music\Video\2008-1\Lonely Island, The Ft. TPain-I'm On A Boat.mpg"
        Dim splits As String()

        line = line.Substring(line.LastIndexOf("\"c) + 1)
        splits = line.Split(","c)
        TextBox1.Text = splits(0)
        TextBox2.Text = splits(1)

    End Sub
  • Marked As Answer byBckSpc Monday, October 19, 2009 12:24 AM
  •  
jwavila  Sunday, October 18, 2009 11:05 PM
I'm not sure where the artist and title separate (is it at the comma?), but you can do this


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim line As String = "D:\Music\Video\2008-1\Lonely Island, The Ft. TPain-I'm On A Boat.mpg"
        Dim splits As String()

        line = line.Substring(line.LastIndexOf("\"c) + 1)
        splits = line.Split(","c)
        TextBox1.Text = splits(0)
        TextBox2.Text = splits(1)

    End Sub
  • Marked As Answer byBckSpc Monday, October 19, 2009 12:24 AM
  •  
jwavila  Sunday, October 18, 2009 11:05 PM

It looks like you are using one of the on-line databases for ripping your CDs. You are in for a lot of manual editing.

If you can I would recommend you set your ripping program to use something like a | for separating the artist and track name rather than a - which will occur in lots of track names.

For the example you have quoted try something like:

Dim Track As String = "D:\Music\Video\2008-1\Lonely Island, The Ft. TPain-I'm On A Boat.mpg"

Dim TrackTitle As String = IO.Path.GetFileNameWithoutExtension(Track)

Dim Elements() As String = TrackTitle.Split("-"c)

MsgBox(Elements(0))

MsgBox(Elements(1))

Dave299  Sunday, October 18, 2009 11:07 PM

You can use google to search for other answers

Custom Search

More Threads

• Populate Combo Box
• File name manipulation
• hash or stream which one is faster ?
• difference between , and . please help
• How Would I Loop Through A ListView And Select Each Item (one by one)
• Link forms
• Register VBexpress but never get a registration key
• Newwindow3
• system.net.ipaddress.parse
• Rich Text