Question
Hello, I need help with a visual basic program that I am working on. I am having building error problems. I will paste the code
Hello, I need help with a visual basic program that I am working on. I am having building error problems. I will paste the code below so that you can maybe try it and see what I am doing wrong.
Instructions: Write a program that lets the user display and modify an address book containing names, e-mail adresses, and phone numbers. The program should contain a class named Address. The Address class should contain the following information about one person: name, e-mail address, phone, and comments. The application should also have a collection named addressList, which stores a collection of Address objects.
Be sure to include code to validate the user's input to make sure no textbox input is blank. Hint: Test your program by leaving a textbox empty to see if it produces the expected outcome. You you must include a class and a collection, add a second form to the project, add comments to the project to explain what the code does, and use a status strip to display all button names in their Spanish equivalents in the project. Thank you.
===========frmEmailAddress.vb=============
Public Class frmEmailAddress Public AddressList As New Collection
'The updateListBox procedure updates the contents of the list box.
Private Sub UpdateListBox()
'Clear the listbox.
lstNames.Items.Clear()
'Load the ID numbers in the collection into the list box.
Dim a As Address
For Each a In AddressList
lstNames.Items.Add(a.Name)
Next
'select the first item in the list.
If lstNames.Items.Count > 0 Then
lstNames.SelectedIndex = 0
End If
End Sub 'Add Button Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'Create an instance of the AddNew form.
frmAddNew.ClearForm()
frmEmailAddress.ShowDialog()
Try
AddressList.Add(frmAddNew.objStudent, frmAddNew.objStudent.Name)
Catch ex As Exception
End Try
UpdateListBox()
End Sub
'Remove Button Function Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Dim intIndex As Integer
'Mak sure an item is selected.
If lstNames.SelectedIndex -1 Then
'confirm that the user wants to remove the item.
If MessageBox.Show("Are You sure?", "Confirm Deletion", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
'Rtrive the student's data from the collection.
intIndex = lstNames.SelectedIndex
Try
'Remove the selected item from the collection.
AddressList.Remove(lstNames.SelectedItem.ToString())
'update the list box.
UpdateListBox()
Catch ex As Exception
'Error message.
MessageBox.Show(ex.Message)
End Try
End If
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If lstNames.SelectedIndex -1 Then
Dim st As New Address
st = AddressList.Item(lstNames.SelectedItem.ToString())
frmAddNew.txtName.Text = st.Name
frmAddNew.txtMail.Text = st.EMail
frmAddNew.txtPhone.Text = st.Phone
frmAddNew.rtbNotes.Text = st.Comments
frmAddNew.ShowDialog()
AddressList.Remove(st.Name)
AddressList.Add(frmAddNew.objStudent, frmAddNew.objStudent.Name)
UpdateListBox()
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click Application.Exit()
End Sub
Private Sub frmEmailAddress_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub End Class
=============frmAddNew.vb================
Public Class frmAddNew
'Create an instance of the address class.
Public objStudent As New address
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'Get data from the form into the object.
objStudent.Name = txtName.Text
objStudent.Phone = txtPhone.Text
objStudent.EMail = txtMail.Text
objStudent.Comments = rtbNotes.Text
ClearForm()
Me.Close()
End Sub 'The clearForm procedure clears the form.
Public Sub ClearForm()
'Clear the text boxes.
txtMail.Clear()
txtName.Clear()
txtPhone.Clear()
rtbNotes.Clear()
'Reset the focus.
txtName.Focus()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click 'Create an instance of the Main Form form.
Me.Close()
End Sub
End Class
==========address.vb===========
Public Class address
Private personName As String
Private personEmail As String
Private personPhone As String
Private personComments As String
Public Property Name As String
Set(ByVal value As String)
personName = value
End Set
Get
Return personName
End Get
End Property
Public Property EMail As String
Set(ByVal value As String)
personEmail = value
End Set
Get
Return personEmail
End Get
End Property
Public Property Phone As String
Set(ByVal value As String)
personPhone = value
End Set
Get
Return personPhone
End Get
End Property
Public Property Comments As String
Set(ByVal value As String)
personComments = value
End Set
Get
Return personComments
End Get
End Property
End Class
Here is the design for the forms. Two forms.
Email Addness Book Application Micnosoft Visual Studlio Express 2012 for Windows Desktop Quick Launch (Ctrl : FILE ECIT VIEW PROJECT BUILO DEBNG TEAM FORMAT TOOLS TEST WINDOW HELP Database Explorer XfmFmailAddress.wh Solution Explorer Add Now Name Scarch Scluticn Fxplorer (Ctri t;) a Sclution Email Address Book Application' (2 projects) 4 AddNew E-muil Adkdress My Project b w addressvb App.config Phone Emall Address Book Application CK & My Project ?? App.config trmEmailAddressvb Prcperlies frmAddNew Systenm.Windwormsrem Deefault Control Backgruundlrtage Rackgrmundlmagel ay Tile Cursor Crror Lis ? E Font Microsoft Sans Serit, T8pt 13 Errors Destriptiu o warnings 0 Messaoes Seatch Lror List File 1 Type Address' is not defined Email Address Bock Applicaliun Email hddress frmFmailAddress 24 Kight IcLet No Talse Add New Nam Falsc 3z TrmAddNew is not dedlared It may be inaccessible due to its protection level. Text 3 Fmail Aidress k Applicatinn.frmFmailAddress canrat refer to itself thrnugh its default rmFmailAddress 47 mail Address instarce, use 'Me' instead. Bock ApplicalionText The lexl assucialed with the cuniral Error List Cutput 3:57 PM O Type here to search Email Addness Book Application Micnosoft Visual Studlio Express 2012 for Windows Desktop Quick Launch (Ctrl : FILE ECIT VIEW PROJECT BUILO DEBNG TEAM FORMAT TOOLS TEST WINDOW HELP Database Explorer XfmFmailAddress.wh Solution Explorer Add Now Name Scarch Scluticn Fxplorer (Ctri t;) a Sclution Email Address Book Application' (2 projects) 4 AddNew E-muil Adkdress My Project b w addressvb App.config Phone Emall Address Book Application CK & My Project ?? App.config trmEmailAddressvb Prcperlies frmAddNew Systenm.Windwormsrem Deefault Control Backgruundlrtage Rackgrmundlmagel ay Tile Cursor Crror Lis ? E Font Microsoft Sans Serit, T8pt 13 Errors Destriptiu o warnings 0 Messaoes Seatch Lror List File 1 Type Address' is not defined Email Address Bock Applicaliun Email hddress frmFmailAddress 24 Kight IcLet No Talse Add New Nam Falsc 3z TrmAddNew is not dedlared It may be inaccessible due to its protection level. Text 3 Fmail Aidress k Applicatinn.frmFmailAddress canrat refer to itself thrnugh its default rmFmailAddress 47 mail Address instarce, use 'Me' instead. Bock ApplicalionText The lexl assucialed with the cuniral Error List Cutput 3:57 PM O Type here to searchStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started