Question: Visual basic help 9. When the user clicks on the Delete Member, the application will verify with an if statement if a name is selected

Visual basic help 9. When the user clicks on the Delete Member, the application will verify with an if statement if a name is selected in the listbox. If a name is not selected the user is presented with an error message and the program quits. If a name is selected, the name is removed from the file and the listbox is refreshed with the new file along with the count being updated. I have started this code but it is not working. rivate Sub mnuadd_Click(sender As Object, e As EventArgs) Handles mnuadd.Click Dim newmember As String = InputBox("Please enter a new member.") Dim sw As IO.StreamWriter = IO.File.AppendText(textfile) sw.WriteLine(newmember) sw.Close() Try sw = IO.File.AppendText(textfile) sw.WriteLine(newmember) sw.Close() LstDisplay.DataSource = Nothing LstDisplay.DataSource = IO.File.ReadAllLines(textfile) Catch exc As System.ArgumentNullException MessageBox.Show("Try again") End Try End Sub Private Sub mnudelete_Click(sender As Object, e As EventArgs) Handles mnudelete.Click If LstDisplay.SelectedIndex = -1 Then MessageBox.Show("Please select a member to be deleted") Return End If Dim deletemember As String = LstDisplay.SelectedItem Dim deletquery = From members In IO.File.ReadLines(textfile) Where members <> deletemember Select members IO.File.WriteAllLines(textfile, deletquery) LstDisplay.DataSource = Nothing LstDisplay.DataSource = IO.File.ReadAllLines(textfile) End Sub

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!