Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help correct correct some of the errors with this program. When a user selects a mission from the lstMissions list box the running total

Please help correct correct some of the errors with this program. When a user selects a mission from the lstMissions list box the running total needs to be displayed in the corresponding mission display label. Also, please help me remove the $ from the hour totals. The output to the user should be a whole number and should not include $.Please include comments in each sub.

Current Code

Public Class Assignment4

Dim missionType() As String

Dim hourAmount(3) As Double

Dim dt As Date = Today

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

missionType = {"Mission 1", "Mission 2", "Mission 3", "Mission 4"}

For Each mission As String In missionType

lstMissions.Items.Add(mission)

Next

lstTotals.Items.Add("Hours Volunteered: " + dt.ToString("D"))

lstTotals.Items.Add("Hours recorded by: Volunteer Cordinator")

lstTotals.Items.Add("__________________________________________")

End Sub

Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click

Me.Close()

End Sub

Private Function ProperOrder(ByVal name As String) As String

Dim first, last As String

Dim names() As String

names = name.Split(",")

first = names(0)

last = names(1)

Return last

End Function

Private Sub btnAddHours_Click(sender As Object, e As EventArgs) Handles btnAddHours.Click

Dim name, formatedName As String

Dim amount As Double

Dim index As Integer

If txtAmount.Text = "" Then

MessageBox.Show("Please enter total hours")

txtAmount.Focus()

Return

End If

If txtName.Text = "" Then

MessageBox.Show("Please enter volunteer name")

txtName.Focus()

Return

End If

name = txtName.Text

amount = Val(txtAmount.Text)

formatedName = ProperOrder(name)

If (missionType(index) = "Mission 1") Then

hourAmount(0) = amount

lblMission1Display.Text = amount.ToString("C")

ElseIf (missionType(index) = "Mission 2") Then

hourAmount(1) = amount

lblMission2Display.Text = amount.ToString("C")

ElseIf (missionType(index) = "Mission 3") Then

hourAmount(2) = amount

lblMission3Display.Text = amount.ToString("C")

ElseIf (missionType(index) = "Mission 4") Then

hourAmount(3) = amount

lblMission4Display.Text = amount.ToString("C")

End If

lstTotals.Items.Add(formatedName & " - Amount Donated " & amount.ToString("C"))

lstTotals.Items.Add(" ")

txtAmount.Clear()

txtName.Clear()

End Sub

Private Sub lblMission1Display_Click(sender As Object, e As EventArgs) Handles lblMission1Display.Click

End Sub Private Sub lblMission2Display_Click(sender As Object, e As EventArgs) Handles lblMission2Display.Click

End Sub Private Sub lstMissions_SelectedIndexChanged(sender As Object, e As EventArgs)

End Sub

Private Sub lblMission4_Click(sender As Object, e As EventArgs) Handles lblMission4Display.Click

End Sub

Private Sub lbl1_Click(sender As Object, e As EventArgs) Handles lbl1.Click

End Sub

Private Sub lstMissions_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles lstMissions.SelectedIndexChanged

End Sub End Class

Assignment Instructions

This module we are going to take the programs we created in three and utilize arrays. You are going to create a program to store the hours for each mission. The application is going to create an array to store 4 different areas of missions. The user is going to enter a name, the number of hours, select a mission, and the information will be displayed and the the totals for the number of hours will be displayed. The totals for the number of hours will be a running total.

1. Form Setup a. Design your screen to look like the one below. b. Update the backcolor to the color of your choice. c. Use appropriate naming conventions for controls and variables.

i. Txt for textbox ii. Lbl for label iii. Frm for form iv. Lst for listbox

d. Tab Control must flow in order from number of hours, lstmissions, Hours, Close. e. All buttons have access keys f. Lock the controls on your form. g. The list box to display the donations must be cleared before written to. h. The amounts will be stored in labels with borders.

2. Code a. Create a comment section at the beginning of the code with the name of the assignment, purpose of the assignment, and your name. Comments must be throughout each sub of the application. b. Remove any subs that are not utilized by the program c. A string array will be created to hold the 5 types of mission entry points.

3. Form Load a. Clear the donation listbox b. Load the mission list array into the listbox c. Display the current Date for the donations d. Display your name

4. Add Donation Button a. The information that was entered should be checked to make sure there are values entered. If the user entry contains null values, the user should be so advised, and the user should be directed to the text box that contains the error. Make sure your error messages are meaningful. b. A static one-dimensional array to hold 4 values is created to hold the number of hours. c. Add the number of hours value into the array in the appropriate place holder based on the selected index d. Display all hour totals in the corresponding labels e. Utilize an input box to get the name from the user. f. Call a function to return back just the last name g. Display the name and the amount donated in the listbox which displays a running total of the amounts entered. h. After the display, clear the selected index of the donation listbox, and amount text box. i. Make sure all spacing is accurate

5. Proper Order Function a. Receives the name b. Uses the substring method to parse out the last name c. Returns the last name

6. Close Button a. The application quits when the button is pressed

Current Form Design

image text in transcribed

String Manipulation and Arrays Programming Assignment Mission 1 Mission 1 Display Mission 4 Mission 4 Display Output Show output from: Debug The program '[11256] Assignment4.NB.exe' has exited with code ()

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago