找到字符串后,如何在VB中输出某一行?

时间:2014-12-31 14:26:59

标签: vb.net windows

我要做的是,在文本文件中找到“日期”一词。我有这部分工作。我想要做的是输出找到“date”一词的整行。 任何想法如何?

Heres the code I have so far?



Dim Findline As String = IO.File.ReadAllText("....\resources\" + ShowsCmb.Text + "-desc.txt") 
Dim Dates As String = "date"

If Findline.Contains(Dates) Then 

'Output the line once the word date has been found <<<Here's where the problem is.
Dates.Readline()Dim Dates As String = "date"

1 个答案:

答案 0 :(得分:0)

您可以使用:

Dim lines as String() = IO.File.ReadAllLines(filename)
For Each line as String in lines
    If line.Contains("date") Then
        Console.WriteLine(line)
    End If
End For