VBGood网站全文搜索 Google

首页 - 经验之谈 - 取得文件内容
发表评论(0)作者:Pritesh, 平台:VB6.0+Win98, 阅读:11354, 日期:2000-10-18
To read a complete file in VB, the normal procedure is to read the contents of the file line by line and accumulate it into a string. Instead, you can use the GET function to read the file with a single call. Doing so simplifies and speeds up the process of reading a file.

You can use the following function:

    Dim Handle As Integer
    Dim FileString As String
    Handle = FreeFile
    Open "C:\TEMP\TST.TXT" For Binary As #Handle
    FileString = Space(FileLen("C:\TEMP\TST.TXT"))
    Get #Handle, ,FileString  
    Close #Handle
This code involves a single call to return the contents of the file.