3
Contributors
3
Replies
18
Views
4 Years
Discussion Span
Last Post by Reverend Jim
0

It's hard to tell, it bases on the type of file you are using. The common way was to fill a dataset with your data from your file, then fill data from dataset to your array.

0

This is the code I have so far, not sure if it'd work tho? Don't really understand the whole StreamReader part

Imports Systom. IO

Dim EmpData(99) As Employee (already made the structure for Employee)

Dim intCount As Integer
Dim strFileName As String
Dim DiskFile As StreamReader

StrFileName = InputBox("Entrer the FileName")

If File.Exists(DiskFile) Then

    Disk File = File.OpenText(strFileName.txt)

    For intCount = 0 to (EmpData.Length-1)
        EmpData(intCount) = Cstr(DiskFile.ReadLine())
    Next
    DiskFile.Close()
Else
    MessageBox.Show("The File does not exist")
End If

Edited by Reverend Jim: fixed formatting

0

First a reminder to please insert code using the Code tool. This preserves formatting. You can avoid the messy details of IO by

If File.Exists(DiskFile) Then

    Dim intCount As Integer = 0

    For Each line As String In System.IO.File.ReadAllLines(strFileName.txt)
        EmpData(intCount) = Cstr(line)
        intCount += 1
        if intCount = EmpData.Length Then Exit For
    Next

Else
    MessageBox.Show("The File does not exist")
End If
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.