Question
Zander Inc. stores employee IDs and salaries in a sequential access file named Employees.txt. Open the VB2015Chap10Zander SolutionZander Solution (Zander Solution.sln) file. Open the Employees.txt
Zander Inc. stores employee IDs and salaries in a sequential access file named Employees.txt. Open the VB2015\Chap10\Zander Solution\Zander Solution (Zander Solution.sln) file. Open the Employees.txt file, which is contained in the projects bin\Debug folder. The ID and salary information appear on separate lines in the file. Close the Employees.txt window. a. Define a structure named Employee. The structure should contain two member variables:
a String variable to store the ID and a Double variable to store the salary.
b. Declare a class-level array that contains five Employee structure variables.
c. The frmMain_Load procedure should read the IDs and salaries from the Employees.txt file and store them in the class-level array. It should also add the IDs to the list box.
d. When the user selects an employee ID in the list box, the employees salary should appear in the lblSalary control.
e. Test the application appropriately.
As of right now this is my code i have 2 errors i will put them in bold. will put in a picture of how it suppose to look.
Option Explicit On Option Strict On Option Infer Off
Public Class frmMain Structure Employee Public strID As String Public dblSalary As String End Structure Private emp(4) As Employee Private strfile As String = "Employees.txt"
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim inFile As IO.StreamReader Dim strId As String Dim intSub As Integer = 0
If IO.File.Exists(strfile) Then inFile = IO.File.OpenText(strfile) Do Until inFile.Peek = -1 strId = inFile.ReadLine lstIds.Items.Add(strId) emp(intSub).strID = strId emp(intSub).dblSalary = Convert.ToDouble(inFile.ReadLine) intSub += 1 Loop inFile.Close()
lstIds.SelectedIndex = 0 Else MessageBox.Show("Can't find" & strfile & "File", "Employees", MessageBoxButtons.OK) End If End Sub Private Sub lstIds_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstIds.SelectedIndexChanged For Each dbElement As Employee In emp If lstIds.SelectedItem.ToString = dbElement.strID Then lblSalary.Text = dbElement.dblSalary.ToString("C2") End If Next End Sub
End Class
Zander Ing. Employee IDs: Salary $15,460 30 1309 407 1410 1503Step 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