小弟用以下方法读取后缀为SQL文件
    Dim str_FileDetail As String
    Dim sA As String
    Open iStr_FileName For Binary As #1
    sA = Space(LOF(1)) '用空格填充sA变量
    Get #1, , sA '用Get语句获取文件全部内容
    RichTextBox1.Text = Replace(sA, " ", ".")
    'RichTextBox1.Text = StrConv(sA, vbUnicode)
    'RichTextBox1.LoadFile iStr_FileName, rtfText
    Close #1
但出来结果是 
S E T   A N S I _N U L L S  NO
G O
我试过用 replace(string," ","" )把空格去掉 结果无效。
请各位赐教。

解决方案 »

  1.   

    这好象是做了全角转换。你的 .sql 用记事本打开正常吗?试试: Dim str_FileDetail As String
        Dim sA() As byte    Open iStr_FileName For Binary As #1
        redim sA(lof(1)-1)
        Get #1, , sA
        RichTextBox1.Text = strConv(sa,vbfromUnicode)
        Close #1
      

  2.   

    用二进制方式读,当然用二进制数组保存数据了。 
    Dim str_FileDetail As String
        'Dim sA As String
         dim sa() as Byte
        Open iStr_FileName For Binary As #1
        redim sa(0 to LoF(1)-1)
        'sA = Space(LOF(1)) '用空格填充sA变量
        
        Get #1, , sa '用Get语句获取文件全部内容
        
        Close #1     RichTextBox1.Text = sa 'Replace(sA, " ", ".")
        'RichTextBox1.Text = StrConv(sA, vbUnicode)
        'RichTextBox1.LoadFile iStr_FileName, rtfText
      

  3.   

    正确的方法是不用转,ANSI赋值到VB的String时,会自动转换成Unicode,你再把他转换成Unicode,每个英文后面就多了个'\0',他不是空格
    redim b(lof(1)) as byte
    get #1,,b
    这样的话可以sa=Strconv(b,vbunicode)
      

  4.   

    SQL文件是以Unicode方式存储的,所以这样就行了:redim b(lof(1)) as byte
    get #1,,b
    sa=b