Question
Need Help on Visual Basic Program. I will add the text file that needs for the Button and I add the code which I had
Need Help on Visual Basic Program. I will add the text file that needs for the Button and I add the code which I had complete. Need Code for Search For Status Button
Public Class frncompexpensepro
Structure ExpenseRecord
Dim RecordNumber As String
Dim EmployeeId As String
Dim ExpenseType As String
Dim TripDescription As String
Dim AmountExpence As Double
Dim DateExpIncurred As Date
Dim ExpenseStatus As String
Dim DatePaid As Date
End Structure
Dim Expenses() As ExpenseRecord
Private Sub frncompexpensepro_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim record() As String = IO.File.ReadAllLines("Expenses.txt")
ReDim Expenses(record.Count - 1)
Dim line As String
Dim data() As String
For i As Integer = 0 To record.Count - 1
line = record(i)
data = line.Split(","c)
Expenses(i).RecordNumber = data(0)
Expenses(i).EmployeeId = Expenses(i).RecordNumber.Substring(0, 6)
Expenses(i).ExpenseType = Expenses(i).RecordNumber.Substring(10, 2)
Expenses(i).TripDescription = data(1)
Expenses(i).AmountExpence = data(2)
Expenses(i).DateExpIncurred = CDate(data(3))
Expenses(i).ExpenseStatus = data(4)
Expenses(i).DatePaid = CDate(data(5))
Next
End Sub
Function ExpenseType(Classification As String) As String
If Classification = "01" Then
Return "Food"
ElseIf Classification = "02" Then
Return "Gas"
ElseIf Classification = "03" Then
Return "Travel Tickets"
ElseIf Classification = "04" Then
Return "Room Cost"
ElseIf Classification = "05" Then
Return "Registration Fee"
ElseIf Classification = "06" Then
Return "Miscellaneous"
End If
End Function
Private Sub BtnListall_Click(sender As Object, e As EventArgs) Handles BtnListall.Click
lstdisplay.Items.Clear()
lstdisplay.Items.Add("List all Expenses")
lstdisplay.Items.Add("")
Dim TotalExpenses As Double
For i As Integer = 0 To Expenses.Count - 1
TotalExpenses += Expenses(i).AmountExpence
lstdisplay.Items.Add("Record Number - " & Expenses(i).RecordNumber)
lstdisplay.Items.Add(Expenses(i).TripDescription & ": " & ExpenseType(Expenses(i).ExpenseType))
lstdisplay.Items.Add(Expenses(i).DateExpIncurred & "- " & Expenses(i).AmountExpence.ToString("C2"))
lstdisplay.Items.Add("")
Next
lstdisplay.Items.Add("Total Expense: " & TotalExpenses)
End Sub
End Class
3 - Search for Status (LINQ) Allow the user to enter an Expenses Status (P/VR). Check to make sure the input is one of these three values. If it isn't, use a message to let the user know what the valid options are. Continue to give them the opportunity to input a valid option (Note: this will require using a loop). Using a query, look through the array to select all records that have the requested status. Display the record number and amount in descending amount order. If no matching records are found to exist, a message should be displayed in the listbox indicating So. Company Expense Reports - X List All Expenses Search for Status Payment Expense Employee Trips Report Expense Type Repor Expenses in StatusP E00242-08-05-001: $800.00 E00242-08-02-001: $75.50 Programmed by: M Smith Exit Form1.vb* Expenses.txt x Form1.vb [Design]* 1 E00123-02-01-001,Orlando Tech Conference, 89.85,01/27/2019,R, 02/15/2019 2 E00123-02-01-002,Orlando Tech Conference, 45.90,01/28/2019,R, 02/15/2019 3 E00123-02-03-001,Orlando Tech Conference, 500.00,01/27/2019, R, 02/15/2019 4 E00123-02-02-001,Orlando Tech Conference, 245.00,01/27/2019,R, 02/15/2019 5 E00123-02-04-001,Orlando Tech Conference, 120.25,01/28/2019, R, 02/15/2019 6 E00242-08-05-001, CyberSecurity Conference, 800.00,03/18/2019,P,01/01/2000 7 E00242-08-02-001, CyberSecurity Conference, 75.50,03/19/2019, P,01/01/2000 8 E00112-01-03-001, Recruiting Trip - North Alabama, 225.00,01/30/2019,I,01/01/2000 9 E00112-01-05-001, Recruiting Trip - North Alabama,155.00,02/01/2019,I,01/01/2000 10 E00112-01-01-001, Recruiting Trip -North Alabama, 45.78,01/30/2019,I,01/01/2000 11 E00112-01-01-002, Recruiting Trip - North Alabama, 82.28,01/31/2019,I,01/01/2000 12 E00112-01-01-003, Recruiting Trip - North Alabama, 38.50,02/01/2019,I,01/01/2000 13 E00242-07-01-001, Gulf Shores Job Fair,12.00,02/20/2019,I,01/01/2000 14 E00242-07-02-001, Gulf Shores Job Fair,15.50,02/20/2019,I,01/01/2000Step 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