在VB6中读取具有数千行和多列的文本文件

时间:2017-03-21 01:08:11

标签: vb6

我尝试读取包含数千行和多列的文本文件,但VB6限制了整个程序只有338行。谁能给我解决这个问题? 这是我已经尝试的代码(该dat是文本文件):

Public TF As Integer, SF As String, NoRs As Integer

Public Type tFile
 Number       As String
 Name         As String
 NIM          As String
 Class        As String
 Room         As String
 Department   As String
 Faculty      As String
 Univ         As String
 Role         As String
End Type

Public myFile(1 To 2650) As tFile '2650 is Number of Rows in my Text File

Public Sub cFile()
 TF = FreeFile
 SF = App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & "String\myfile.dat"

 Open SF For Input As #TF
 NoRs = 0

 Do Until EOF(TF)
  NoRs = NoRs + 1

  With myFile(NoRs)
   Input #TF, _
   .Number, _
   .Name, _
   .NIM, _
   .Class, _
   .Room, _
   .Department, _
   .Faculty, _
   .Univ, _
   .Role
  End With

 Loop
 Close #TF
End Sub

它一直工作到第338行,但如果我向下滚动该行,它将超出范围。

0 个答案:

没有答案