Я пытаюсь прочитать несколько текстовых файлов и отображать их в поле со списком, но почему-то не отображается содержимое, как ожидается, любой совет действительно поможет.
Public Const ARRAYSIZE As Integer = 1000
Public Shared strID(ARRAYSIZE) As String
Public Shared strL_name(ARRAYSIZE) As String
Public Shared strF_name(ARRAYSIZE) As String
Public Shared intclock_in(ARRAYSIZE) As Integer
Public Shared intclock_out(ARRAYSIZE) As Integer
Public Shared intIndex As Integer = 0
Public Shared intHrs(ARRAYSIZE) As Integer
Public Shared intSum(ARRAYSIZE) As Integer
Public Shared intTotal(ARRAYSIZE) As Integer
Public Shared dblGross(ARRAYSIZE) As Double
Public Shared dblTax(ARRAYSIZE) As Double
Public Shared dblNP(ARRAYSIZE) As Double
Private Sub btnFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFile.Click
Dim objFileReader1 As IO.StreamReader
Dim strPath As String
Dim dlrResult As DialogResult
Dim strFields() As String
Dim strLine As String
Try
dlrResult = FileOpener.ShowDialog()
If dlrResult = Windows.Forms.DialogResult.Cancel Then
MsgBox("You have not Selected a file")
Else
strPath = FileOpener.FileName
objFileReader1 = IO.File.OpenText(strPath)
Do While objFileReader1.Peek() <> -1
strLine = objFileReader1.ReadLine()
strFields = strLine.Split(CChar(vbTab))
'storing each field in their respective arrays.
strID(intIndex) = strFields(0)
strL_name(intIndex) = strFields(1)
strF_name(intIndex) = strFields(2)
intclock_in(intIndex) = Convert.ToInt32(strFields(3))
intclock_out(intIndex) = Convert.ToInt32(strFields(4))
'Calculate the net wages
intHrs(intIndex) = (intclock_out(intIndex)) - (intclock_in(intIndex))
intSum(intIndex) = intSum(intIndex) + intHrs(intIndex)
dblGross(intIndex) = intSum(intIndex) * 9.5
dblTax(intIndex) = (dblGross(intIndex) / 100) * 8
dblNP(intIndex) = dblGross(intIndex) - dblTax(intIndex)
intIndex += 1
Loop
'lstDisplay.Items.Add(strID(0) & " " & strL_name(0) & " " & strF_name(0) & " " & intclock_in(0) & " " & intclock_out(0))
objFileReader1.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
For subscript = 0 To intIndex - 1
cbxDisplay.Items.Add(strID(subscript) & " " & strL_name(subscript) & " " & strF_name(subscript) & " " & intclock_in(subscript) & " " & intclock_out(subscript))
Next