Click here to Skip to main content
15,901,284 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: listbox mass edit Pin
Member Alienoiz10-Jun-23 6:53
Member Alienoiz10-Jun-23 6:53 
GeneralRe: listbox mass edit Pin
Member Alienoiz10-Jun-23 6:59
Member Alienoiz10-Jun-23 6:59 
GeneralRe: listbox mass edit Pin
Dave Kreskowiak10-Jun-23 19:21
mveDave Kreskowiak10-Jun-23 19:21 
GeneralRe: listbox mass edit Pin
Member Alienoiz10-Jun-23 23:05
Member Alienoiz10-Jun-23 23:05 
GeneralRe: listbox mass edit Pin
Richard MacCutchan11-Jun-23 1:31
mveRichard MacCutchan11-Jun-23 1:31 
GeneralRe: listbox mass edit Pin
Member Alienoiz11-Jun-23 1:49
Member Alienoiz11-Jun-23 1:49 
GeneralRe: listbox mass edit Pin
Richard MacCutchan11-Jun-23 1:58
mveRichard MacCutchan11-Jun-23 1:58 
GeneralRe: listbox mass edit Pin
Member Alienoiz11-Jun-23 2:45
Member Alienoiz11-Jun-23 2:45 
Hey..i know im lame..but i have (and sorry for the exctensive code) written all this just using internet snippets and my own knowledge without asking for help to anyone...but...yes...i cannot solve the listbox mass edit..
anyway..thanks for replying...
VB.NET
<pre>Imports System.IO
Imports System.Net.Security
Imports System.Net.WebRequestMethods
Imports System.Runtime
Imports System.Security.Cryptography
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
Imports HundredMilesSoftware.UltraID3Lib

Public Class Form1

    Dim myMp3 As New UltraID3()

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then

            ListBox1.Items.Clear()
            Dim fileNames = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")

            For Each fileName As String In fileNames
                Dim result As String = Path.GetFileName(fileName)
                ListBox1.Items.Add(result)
            Next


        End If
        Label1.Text = "Title :"
        Label2.Text = "Artist :"
        Label3.Text = "Album :"
        Label4.Text = "Year :"
        Label5.Text = "Track :"
        Label6.Text = "Comment :"
        Label7.Text = "Genre : "

    End Sub



    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ListBox1.Items.Clear()
        If FolderBrowserDialog1.SelectedPath = "" Then
            Dim r8 As DialogResult = MessageBox.Show(Me, "You need to load a folder.",
                                   "Load Files", MessageBoxButtons.OK)
        Else
            Dim fileNames = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")

            For Each fileName As String In fileNames
                Dim result As String = Path.GetFileName(fileName)
                ListBox1.Items.Add(result)
            Next

        End If


        Label1.Text = "Title :"
        Label2.Text = "Artist :"
        Label3.Text = "Album :"
        Label4.Text = "Year :"
        Label5.Text = "Track :"
        Label6.Text = "Comment :"
        Label7.Text = "Genre : "
    End Sub



    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged

        If ListBox1.SelectedItem = "" Then
            On Error Resume Next
        Else

            myMp3.Read(FolderBrowserDialog1.SelectedPath & "\" & ListBox1.SelectedItem)

            Label1.Text = "Title : " & myMp3.ID3v2Tag.Title
            Label2.Text = "Artist : " & myMp3.ID3v2Tag.Artist
            Label3.Text = "Album : " & myMp3.ID3v2Tag.Album
            Label4.Text = "Year : " & myMp3.ID3v2Tag.Year.ToString
            Label5.Text = "Track : " & myMp3.ID3v2Tag.TrackNum.ToString
            Label6.Text = "Comment : " & myMp3.ID3v2Tag.Comments
            Label7.Text = "Genre : " & myMp3.ID3v2Tag.Genre
            On Error Resume Next
            Dim pics = myMp3.ID3v2Tag.Frames.GetFrames(CommonMultipleInstanceID3v2FrameTypes.Picture)
            PictureBox1.Image = CType(pics(0), ID3v2PictureFrame).Picture

        End If

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


        If ListBox1.SelectedItem = "" Then
            Dim r8 As DialogResult = MessageBox.Show(Me, "No File Selected!",
                                   "Select Files", MessageBoxButtons.OK)


        Else
            If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False And CheckBox5.Checked = False And CheckBox6.Checked = False And CheckBox7.Checked = False And CheckBox8.Checked = False Then
                Dim r8 As DialogResult = MessageBox.Show(Me, "Select a tag to enter!",
                                  "Select Tags", MessageBoxButtons.OK)
            Else
                If CheckBox1.Checked = True Then
                    myMp3.ID3v2Tag.Title = TextBox1.Text
                    myMp3.Write()
                End If

                If CheckBox2.Checked = True Then
                    myMp3.ID3v2Tag.Artist = TextBox2.Text
                    myMp3.Write()
                End If


                If CheckBox3.Checked = True Then
                    myMp3.ID3v2Tag.Album = TextBox3.Text
                    myMp3.Write()
                End If


                If CheckBox4.Checked = True And TextBox4.Text <> "" Then
                    On Error Resume Next
                    myMp3.ID3v2Tag.Year = Short.Parse(TextBox4.Text)
                    myMp3.Write()

                End If
                If CheckBox5.Checked = True And TextBox5.Text <> "" Then
                    On Error Resume Next
                    myMp3.ID3v2Tag.TrackNum = Short.Parse(TextBox5.Text)
                    myMp3.Write()

                End If
                If CheckBox6.Checked = True Then
                    myMp3.ID3v2Tag.Comments = TextBox6.Text
                    myMp3.Write()
                End If

                If CheckBox7.Checked = True Then
                    If ComboBox1.Text = "01 - User" Then
                        myMp3.ID3v2Tag.Genre = TextBox7.Text
                        myMp3.Write()
                    Else
                        myMp3.ID3v2Tag.Genre = ComboBox1.Text
                        myMp3.Write()
                    End If

                    If CheckBox8.Checked = True Then
                        Dim AlbumArt As ID3v2PictureFrame = New ID3v23PictureFrame(System.Drawing.Bitmap.FromFile("E:\teste\img.jpg"), PictureTypes.CoverFront, "Attached picture", TextEncodingTypes.ISO88591)
                        AlbumArt.Picture = PictureBox1.Image
                        myMp3.ID3v2Tag.Frames.Add(AlbumArt)
                        myMp3.Write()
                    End If

                End If
            End If
            Dim r9 As DialogResult = MessageBox.Show(Me, "Operation Complete!",
                          "Tagged Files!", MessageBoxButtons.OK)
        End If
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        ListBox1.Items.Clear()
    End Sub

    Private Sub TextBox5_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox5.KeyPress
        Dim ch As Char = e.KeyChar
        If Not Char.IsDigit(ch) AndAlso Asc(ch) <> 8 Then
            e.Handled = True
        End If
    End Sub

    Private Sub TextBox4_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox4.KeyPress
        Dim ch As Char = e.KeyChar
        If Not Char.IsDigit(ch) AndAlso Asc(ch) <> 8 Then
            e.Handled = True
        End If
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        On Error Resume Next
        My.Computer.FileSystem.RenameFile(FolderBrowserDialog1.SelectedPath & "\" & ListBox1.SelectedItem, TextBox8.Text & ".mp3")

        ListBox1.Items.Clear()

        Dim Fils = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")

        For Each fil As String In Fils
            Dim result As String = Path.GetFileName(fil)
            ListBox1.Items.Add(result)
        Next
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        On Error Resume Next
        Dim FileName = ListBox1.SelectedItem

        Dim FilePath = TextBox9.Text & "\" & FileName  'First Name of Directory and Then Name of Folder if it exists and then attach the name of file you want to search.

        If System.IO.File.Exists(FilePath) Then
            Dim r9 As DialogResult = MessageBox.Show(Me, "File Exists!",
                           "Duplicated Files!", MessageBoxButtons.OK)
        Else
            My.Computer.FileSystem.MoveFile(FolderBrowserDialog1.SelectedPath & "\" & ListBox1.SelectedItem, TextBox9.Text & "\" & ListBox1.SelectedItem)
            ListBox1.Items.Clear()
            Dim fils2 = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")

            For Each fil3 As String In fils2
                Dim result As String = Path.GetFileName(fil3)
                ListBox1.Items.Add(result)
            Next

        End If

    End Sub

    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        If FolderBrowserDialog2.ShowDialog() = DialogResult.OK Then
            TextBox9.Text = FolderBrowserDialog2.SelectedPath
        End If
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        On Error Resume Next

        Dim FileName = ListBox1.SelectedItem

        Dim FilePath = TextBox10.Text & "\" & FileName  'First Name of Directory and Then Name of Folder if it exists and then attach the name of file you want to search.

        If System.IO.File.Exists(FilePath) Then
            Dim r9 As DialogResult = MessageBox.Show(Me, "File Exists!",
                           "Duplicated Files!", MessageBoxButtons.OK)
        Else
            My.Computer.FileSystem.CopyFile(FolderBrowserDialog1.SelectedPath & "\" & ListBox1.SelectedItem, TextBox10.Text & "\" & ListBox1.SelectedItem, overwrite:=False)

            ListBox1.Items.Clear()
            Dim fils4 = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")

            For Each fil4 As String In fils4
                Dim result As String = Path.GetFileName(fil4)
                ListBox1.Items.Add(result)
            Next
        End If
    End Sub

    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        If FolderBrowserDialog3.ShowDialog() = DialogResult.OK Then
            TextBox10.Text = FolderBrowserDialog3.SelectedPath
        End If
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        On Error Resume Next
        My.Computer.FileSystem.DeleteFile(FolderBrowserDialog1.SelectedPath & "\" & ListBox1.SelectedItem)
        ListBox1.Items.Clear()
        Dim fils5 = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")

        For Each fil5 As String In fils5
            Dim result As String = Path.GetFileName(fil5)
            ListBox1.Items.Add(result)
        Next

    End Sub

    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        Dim ofd As New OpenFileDialog
        If ofd.ShowDialog = DialogResult.OK Then
            If ofd.FileName <> String.Empty Then
                Me.PictureBox1.Image = Bitmap.FromFile(ofd.FileName)
            End If
        End If
    End Sub

    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        For i As Integer = 0 To ListBox1.SelectedIndices.Count - 1
            ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
        Next

    End Sub

    Private Sub TextBox11_TextChanged(sender As Object, e As EventArgs) Handles TextBox11.TextChanged
        If TextBox11.Text = "" Then
            ListBox1.Items.Clear()
            Dim fileNames = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")

            For Each fileName As String In fileNames
                Dim result As String = Path.GetFileName(fileName)
                ListBox1.Items.Add(result)
            Next
        Else

            Dim items = From it In ListBox1.Items.Cast(Of Object)()
                        Where it.ToString().IndexOf(TextBox11.Text, StringComparison.CurrentCultureIgnoreCase) >= 0
            Dim matchingItemList As List(Of Object) = items.ToList()
            ListBox1.BeginUpdate()
            ListBox1.Items.Clear()
            For Each item In matchingItemList
                ListBox1.Items.Add(item)
            Next
            ListBox1.EndUpdate()
        End If
    End Sub

    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        If Button13.Text = "Mass Edit" Then
            Button13.Text = "Single Edit"
        Else
            Button13.Text = "Mass Edit"
        End If

        If Button5.Enabled = True Then
            Button5.Enabled = False
        Else
            Button5.Enabled = True
        End If
        If Button6.Enabled = True Then
            Button6.Enabled = False
        Else
            Button6.Enabled = True
        End If
        If Button7.Enabled = True Then
            Button7.Enabled = False
        Else
            Button7.Enabled = True
        End If
        If Button8.Enabled = True Then
            Button8.Enabled = False
        Else
            Button8.Enabled = True
        End If
        If ListBox1.SelectionMode = SelectionMode.One Then
            ListBox1.SelectionMode = SelectionMode.MultiExtended
        Else
            ListBox1.SelectionMode = SelectionMode.One
        End If


    End Sub
End Class

GeneralRe: listbox mass edit Pin
Dave Kreskowiak11-Jun-23 4:38
mveDave Kreskowiak11-Jun-23 4:38 
GeneralRe: listbox mass edit Pin
Member Alienoiz11-Jun-23 5:01
Member Alienoiz11-Jun-23 5:01 
GeneralRe: listbox mass edit Pin
Dave Kreskowiak11-Jun-23 5:10
mveDave Kreskowiak11-Jun-23 5:10 
GeneralRe: listbox mass edit Pin
Member Alienoiz11-Jun-23 5:13
Member Alienoiz11-Jun-23 5:13 
GeneralRe: listbox mass edit Pin
Dave Kreskowiak11-Jun-23 5:23
mveDave Kreskowiak11-Jun-23 5:23 
GeneralRe: listbox mass edit Pin
Member Alienoiz11-Jun-23 5:29
Member Alienoiz11-Jun-23 5:29 
GeneralRe: listbox mass edit Pin
Dave Kreskowiak12-Jun-23 2:20
mveDave Kreskowiak12-Jun-23 2:20 
GeneralRe: listbox mass edit Pin
Member Alienoiz11-Jun-23 23:37
Member Alienoiz11-Jun-23 23:37 
GeneralRe: listbox mass edit Pin
Richard MacCutchan12-Jun-23 2:05
mveRichard MacCutchan12-Jun-23 2:05 
GeneralRe: listbox mass edit Pin
Dave Kreskowiak11-Jun-23 4:52
mveDave Kreskowiak11-Jun-23 4:52 
GeneralRe: listbox mass edit Pin
Member Alienoiz11-Jun-23 5:02
Member Alienoiz11-Jun-23 5:02 
GeneralRe: listbox mass edit Pin
Member Alienoiz10-Jun-23 9:53
Member Alienoiz10-Jun-23 9:53 
GeneralRe: listbox mass edit Pin
Ralf Meier10-Jun-23 10:52
mveRalf Meier10-Jun-23 10:52 
GeneralRe: listbox mass edit Pin
Richard MacCutchan10-Jun-23 21:23
mveRichard MacCutchan10-Jun-23 21:23 
AnswerRe: listbox mass edit Pin
Richard MacCutchan10-Jun-23 21:11
mveRichard MacCutchan10-Jun-23 21:11 
AnswerRe: listbox mass edit Pin
Andre Oosthuizen12-Jun-23 23:59
mveAndre Oosthuizen12-Jun-23 23:59 
GeneralRe: listbox mass edit Pin
Member Alienoiz13-Jun-23 1:03
Member Alienoiz13-Jun-23 1:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.