Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions

Question

Solve the following 1,4 3 2TT 5x- 1+ (15 x) dx 5X

Answered: 1 week ago

Question

3. Describe the communicative power of group affiliations

Answered: 1 week ago