This program is to be done in visual basic I need both the code and the gui. The
ID: 3831291 • Letter: T
Question
This program is to be done in visual basic I need both the code and the gui.
The MemberPhones.txt contains the below info.
Langley, Judy
321-1111
Morgan, Fred
222-2222
Nixon, Mike
333-3333
Norton, Herbert
444-4444
Preiss, Carol
555-5555
Ree, Alice
666-6666
Sanchez, Carlos
777-7777
Smith, John
888-8888
Explanation / Answer
Public Class Form1
Class Member
Public Name As String
Public Phone As String
End Class
Dim memberList As New List(Of Member)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sr() As String = IO.File.ReadAllLines("residents.TXT")
Dim memberline() As String
For j As Integer = 0 To sr.Count - 1
MemberLine = sr(j).Split(","c)
ListBox1.Items.Add(memberline(0))
Next
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim sr() As String = IO.File.ReadAllLines("residents.TXT")
Dim theindex As String = ListBox1.SelectedItem
Dim list() As String
list = sr(theindex).Split(","c)
TextBox1.Text = list(0)
TextBox2.Text = list(1)
End Sub
Private Sub ModifyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModifyToolStripMenuItem.Click
memberList(ListBox1.SelectedIndex).Name = TextBox1.Text
memberList(ListBox1.SelectedIndex).Phone = TextBox2.Text
RefreshLstInfo()
End Sub
Private Sub AddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click
Dim NewPerson As New Member
NewPerson.Name = TextBox1.Text
NewPerson.Phone = TextBox2.Text
ListBox1.Items.Add(TextBox1.Text & "," & TextBox2.Text)
RefreshLstInfo()
End Sub
Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click
memberList.RemoveAt(ListBox1.SelectedIndex)
RefreshLstInfo()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub RefreshLstInfo()
ListBox1.Items.Clear()
For j As Integer = 0 To memberList.Count - 1
ListBox1.Items.Add(memberList(j).Name)
Next
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.