vb.net 按行读取字符串

dim a as string然后a 的值是。"AAa", "BBB“, "CCC" 三行内容,注意是三行用最简单的方法分别读取每一行。
2026年09月28日 03:31
有2个网友回答
网友(1):

给你一个VB2010读写文件的例子吧

Dim name As String = ""
        Dim age As Integer
        name = InputBox("请输入姓名")
        age = InputBox("请输入年龄")

        FileOpen(1, "d:\信息.txt", OpenMode.Append)
        WriteLine(1, name, age)
        FileClose(1)



 FileOpen(1, "d:\信息.txt", OpenMode.Input)
        Dim h As String
        Dim j As String
        Dim f As String
        f = ""
        h = ""
        j = ""
        While EOF(1) = False
            f = LineInput(1) & vbCrLf & f
        End While
        FileClose(1)
        MsgBox("姓名" & "  " & "年龄" & vbCrLf & f)

网友(2):

//VB

        For Each line As String In a.Split(vbNewLine)
            MsgBox(line)
        Next

 用了就更改采纳