在Visual Basic中将文件拆分为数组

时间:2018-10-11 10:55:44

标签: excel vb.net

我正在尝试将文件拆分为数组。

Structure Users
    Dim Name As String
    Dim Surname As String
    Dim Address As String
    Dim AccountNo As String
    Dim PIN As String
    Dim Balance As Decimal
End Structure

这是我需要填充XSL文件的结构;可以轻松将其更改为CSV
我只需要帮助将此文件拆分为结构即可。

Sub LoadDatabase(ByRef Accounts() As Users, ByVal lineCount As Integer)
    Dim file(lineCount) As Users

    FileOpen(1, "Database.xsl", OpenMode.Input)
    file = Input(LOF(1), 1)

    For i = 1 To lineCount
        Accounts(i).Name = Split(file(i), ",")
    Next

    FileClose(1)
End Sub

Excel文件如下所示:

enter image description here

0 个答案:

没有答案