vb读取文件并在文本框中显示

来源:互联网 发布:linux 自动执行脚本 编辑:程序博客网 时间:2024/05/14 07:17

    Dim Str1 As String
    Dim Str2 As String
    Dim StrFileName As String

    StrFileName = App.Path & "/1.txt" '获取文本文件路径
    Open StrFileName For Input As #1 '打开文件
    Do Until EOF(1) '判断是否末尾
        Line Input #1, Str1 '逐行读取
        Str2 = Str2 & Str1 & vbCrLf '获取文本 'vbCrLf 回车符
    Loop
    Text1.Text = Str2  'text1的MultiLine设置为ture
    Close #1