Visual Basic Zander Inc. stores employee IDs and salaries in a sequential access
ID: 3820247 • Letter: V
Question
Visual Basic
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 file, which is contained in the project’s binDebug 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 employee’s salary should appear in the lblSalary control.
e. Test the application appropriately.
1305 15460 1309 16700 1407 21000 1410 23000 1503 18500 Zander Inc Employee IDs: Istlds Sala ExitExplanation / Answer
Hi,
Please find partial section of your request-
Public Class Form1
Structure Address
'Structure contains User's personal information
Dim ID As String
Dim salary As Double
End Structure
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim line As String
Dim total As Integer
total = 0
Using reader As New IO.StreamReader("C:UsersinayDesktop.txt")
While Not reader.EndOfStream
line = reader.ReadLine
'MsgBox(line)
Dim value As Integer
If Integer.TryParse(line, value) Then
total = total + value
End If
Dim Units() As Address
Dim fileContents() As String = IO.File.ReadAllLines("C:UsersinayDesktop.txt")
ReDim Units(fileContents.Length)
For i = 0 To fileContents.Length - 1
Units(i) = New Address(fileContents(i))
Next
If line Mod 2 = 0 Then
''# even line
Else
''# odd line
End If
End While
End Using
MsgBox(total)
End Sub
End Class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.