我无法让我的程序读取文本文档的第二行

时间:2013-05-26 14:00:25

标签: vb.net

好吧所以我试图让我的程序读取文本文件的特定行。我创建了两个标签,一个标记为TheFileName,另一个标记为TheText。一切正常,除了我无法弄清楚如何让它读取第二行,只有第二行。

代码:

Dim Rlo As New IO.StreamReader(“C:\ Users \ Alex \ Documents \ Visual Studio 2012 \ Projects \ RobloxRecruitV1 \ RobloxRecruitV1 \ bin \ Debug \”& TheFileName.Text&“。txt”)

TheText.Text = Rlo.ReadLine(2)

1 个答案:

答案 0 :(得分:2)

Dim Rlo As New IO.StreamReader("C:\Users\Alex\Documents\Visual Studio 2012\Projects\RobloxRecruitV1\RobloxRecruitV1\bin\Debug\" & TheFileName.Text & ".txt")

Dim firstLine As String
'read first line
firstLine = Rlo.ReadLine()
'read secondline
TheText.Text = Rlo.ReadLine()