一个sql file,有51万行,用    Open path For Input As #1
它会将所有行read读完才开始工作,直至内存用光
请问有什么方法解决?
msgbox 一直弹不出来,假如未能将文件完全读入'Read the sql file
Private Sub readFile(ByVal path As String)
On Error GoTo myerror
    Dim str As String
    Dim counter As Integer
    Open path For Input As #1
    counter = 0
    Do While Not EOF(1)
        Input #1, str
        counter = counter + 1
        Form1.Caption = counter & str
        frmSplash.Show
        Call Form1.updateCustomerTotalNumberPages(str)
        Unload frmSplash
    Loop
    Close #1
    Exit Sub
myerror:
    MsgBox ("Open file failed")
    Exit Sub
End Sub

解决方案 »

  1.   

    建议一次性将数据读入:
    'Read the sql file
    Private Sub readFile(ByVal path As String)
    On Error GoTo myerror
        Dim str As String
        Dim counter As long    Open path For Input As #1
        counter = 0
        Do While Not EOF(1)
            Input #1, str
            counter = counter + 1
            Form1.Caption = counter & str
            frmSplash.Show
            Call Form1.updateCustomerTotalNumberPages(str)
            Unload frmSplash
        Loop
        Close #1
        Exit Sub
    myerror:
        MsgBox ("Open file failed")
        Exit Sub
    End Sub
      

  2.   

    抱歉,不知怎么的,就给回复了,我还没有修改完呢:
    'Read the sql file
    Private Sub readFile(ByVal path As String)
    On Error GoTo myerror
        dim mstr as string
        dim i as long
        i=filelen(path)
        dim bytearr() as byte
        redim bytearr(i-1)
        frmSplash.Show
        Open path For binary As #1
        get #1,,bytearr
        Close #1
         mstr=strconv(bytearr,vbunicode)
         Call Form1.updateCustomerTotalNumberPages(mstr)
         Unload frmSplash  
         exit sub
    myerror:
        MsgBox ("Open file failed")
        'Exit Sub
    End Sub