请问:
假设"C:\"有一文件"words.txt",其内容为(带双引号为内容):
第一行: "111"
第二行: "222"
第三行: "333"又假设Form上有Text1、Text2、Text3,请问如何分别把"111"读入text1、"222"读入text2、"333"读入text3?
感谢各位.

解决方案 »

  1.   

    用Split函数
    将打开的内容赋给一个变量(如strText)
    定义一个数组str()
    str = split(strText,vbCrlf)
    text1.text = str(0)
    text2.text = str(1)
    text3.text = str(2)
      

  2.   

    '添加Microsoft Script Run Time的 引用
    Private Sub Command1_Click()
        Dim fsoObject As New FileSystemObject
        Dim fileObject As File
        Dim s As TextStream
        Set s = fsoObject.OpenTextFile("c:\words.txt")
        Dim str As String
        str = s.ReadAll
        Dim strArr() As String
        strArr = Split(str, vbCrLf)
        Dim i As Integer
        Text1 = strArr(0)
        Text2 = strArr(1)
        Text3 = strArr(2)
    End Sub
      

  3.   

    Private Sub Command3_Click()
        Dim sFile As String
        Dim tmp() As String     Open App.Path & "\a.txt" For Input As #1
            Do While Not EOF(1)
                Line Input #1, stmp
                sFile = sFile + stmp + vbCrLf
            Loop
        Close #1
        tmp() = Split(sFile, vbCrLf, -1)
        Text1.Text = tmp(0)
        Text2.Text = tmp(1)
        Text3.Text = tmp(2)
    End Sub