如下:没什么我得到的还是一个二进制的文件?
Private Sub RandomRead(ByVal inputFileName As String, ByVal outFileName As String)
    Open inputFileName For Binary As #1
    lFileSize = LOF(1)
    ReDim buffer(lFileSize) As Byte
    
    Get #1, , buffer
    Close #1
    Dim aa As String
    For i = 0 To lFileSize
       aa = aa + Chr(buffer(i))
    Next
    'aa = StrConv(buffer(), vbUnicode)
    'MsgBox aa
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    fs.CreateTextFile outFileName
    Set fileOUT = fs.GetFile(outFileName)
    Set ws = fileOUT.OpenAsTextStream(2, 0)
    
    ws.Write aa
    ws.Close
End Sub

解决方案 »

  1.   

    Private Sub RandomRead(ByVal inputFileName As String, ByVal outFileName As String)
        Open inputFileName For Binary As #1
        lFileSize = LOF(1)
        ReDim buffer(lFileSize-1) As Byte
        
        Get #1, , buffer
        Close #1
        Dim aa As String
        'For i = 0 To lFileSize
        '   aa = aa + Chr(buffer(i))
        'Next
        aa = StrConv(buffer, vbUnicode)
        MsgBox aa
        
        'Set fs = CreateObject("Scripting.FileSystemObject")
        'fs.CreateTextFile outFileName
        'Set fileOUT = fs.GetFile(outFileName)
        'Set ws = fileOUT.OpenAsTextStream(2, 0)
        '
        'ws.Write aa
        'ws.Close
    End Sub这种情况学要你的文件比较小,如果大的话,可以发批来处理!
      

  2.   

    因为以前的数据是放在二进制文件中的,现在要把文件中的记录取出来放到Sql数据库中
    这个文件在这里拿位朋友能够帮忙看看
    http://www.0755i.com/temp/temp.001没有用过还请大家多指导
      

  3.   

    呵呵,大哥,你真有意思
    你的那个文件我看了,如果一定要用VB的话,你可以用数护库的方式打开那个文件
    注意名字(不是DBF结尾的)
    那个文件是DBASE 或 FoxBase的数据库,不过不知道为什么改的名字,有没有索引文件什么的,你最好是看一下那个文件,我用FOXBASE试了一下,能打开
    如果你不是练习程序的话,最好是用数据库的方法来做,那样比较结省力,呵呵
    如果一定要用VB打开二进制文件的话,你最好是先找一找关于DBF文件格式的资料,一般用C来读DBF文件的资料比较多,你可以看看
      

  4.   

    没办法,要求一定要用VB的,我又没有用过VB:(,不过还好问题解决了:)
    谢谢各位