Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Visual Basic Create a program that allows a user to create, edit and save

ID: 3581074 • Letter: U

Question

Using Visual Basic

Create a program that allows a user to create, edit and save phonebook data. The program should contain textboxes for a first name, last name, and phone number. It should also contain a Next, Previous and Exit button. All data is stored in the numbers table of the PhoneBook.mdb database file. When the program first starts, the database should be loaded into a DataSet and the text boxes on the form should be populated with data. When the Next button is clicked the data in the text boxes should be replaced with data from the next record of the dataset. When the Previous button is clicked the data in the text boxes should be replaced with data from the previous record of the dataset. When the Exit button is clicked, the program should check for exceptions. If an exception occurs the user should be notified and given the option to exit anyway. If no exception occurs the data should be permanently saved in the database, the user should be notified and the program should close.

Explanation / Answer

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        Dim item As String = TextBox1.Text.ToString()

        Dim index As Integer = ListBox1.FindString(item)

  

        If index = -1 Then

            ListBox1.SelectedIndex = ListBox1.SelectedIndex

        Else

            ListBox1.SetSelected(index, True)

        End If

    End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Form2.Show()

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Try

            For Each Name As String In My.Settings.Names

                ListBox1.Items.Add(Name)

            Next

        Catch ex As Exception

        End Try

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If ListBox1.SelectedIndex < 0 Then

        Else

            Dim ask As MsgBoxResult

            ask = MsgBox("Are you sure you want to remove " & ListBox1.SelectedItem & " ?", MsgBoxStyle.YesNo)

            If ask = MsgBoxResult.Yes Then

                My.Settings.Names.Remove(ListBox1.SelectedItem)

                My.Settings.Save()

                ListBox1.Items.Clear()

                For Each Name As String In My.Settings.Names

                    ListBox1.Items.Add(Name)

                Next

            ElseIf ask = MsgBoxResult.No Then

  

            End If

        End If

    End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Close()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        If My.Settings.Names Is Nothing Then

            If TextBox1.Text = "" Or TextBox2.Text = "" Then

                MsgBox("Must Fill all Fields")

            Else

                My.Settings.Names.Add(TextBox1.Text + " - " + TextBox2.Text)

                My.Settings.Save()

                Me.Close()

            End If

        Else

            If TextBox1.Text = "" Or TextBox2.Text = "" Then

                MsgBox("Must Fill all Fields")

            Else

                My.Settings.Names.Add(TextBox1.Text + " - " + TextBox2.Text)

                My.Settings.Save()

                Me.Close()

  

            End If

  

        End If

        TextBox1.Clear()

        TextBox2.Clear()

        Form1.ListBox1.Items.Clear()

        For Each Name As String In My.Settings.Names

            Form1.ListBox1.Items.Add(Name)

        Next

End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote