现遇到如下问题,向各位兄弟请教一把在VB中,
我打开一个文件并一行一行读取下来,但是中文字符却不能读取/显示
以下是我的Demo代码
Sub Main()
Dim sFileName As String
Dim srFileReader As System.IO.StreamReader
Dim sInputLine As StringsFileName = "f:\1.txt"
srFileReader = System.IO.File.OpenText(sFileName)
sInputLine = srFileReader.ReadLine()
Do Until sInputLine Is Nothing
Console.WriteLine(sInputLine)
// 在此中文显示不了,debug跟踪发现,它好像跳过了一部分字节
sInputLine = srFileReader.ReadLine()
Loop
srFileReader.Close()
Console.WriteLine("可以吗?")
// 直接打印,能够正常输出
End Sub
对于这个问题,我应该如何解决.

解决方案 »

  1.   

    Dim sFileName As String
    Dim sInputLine As String
    open filename for input as #1
        while not eof(1)
            line input 1,sInputLine 
            Console.WriteLine(sInputLine)
        wend
    close #1
      

  2.   

    不应该啊,你可以换成File I/O来试一下
    Dim I As Long
    I = 1
    Open sFileName For Input As #1
         Do While Not EOF(1)
            Line Input #1, sInputLine
            Debug.Print I, sInputLine
            I = I + 1
         Loop
         
    Close #1
      

  3.   

    我用的vb .net好像跟6.0差别很大阿
    以前没用过vb
    现编写一个数据导入的小程序(从文本导入到
    Access数据库)
    哪位兄弟也用.net帮我解决一下阿