0

Good day.

I wana know what is the code (VB 2008) to get line that contains selected data that the user want from notepad?

example: apple, red, 180
pear, green, 200
melon, yellow, 250

the user will type "apple" in the textbox and the msgbox will tell in which line "apple" is in... answer : 1

how it can be done? i'm sooo light headed thinking of this...PLS PLS!

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by afylegacy
0

here is a simple code for that:

Dim c As Integer = 1
        Dim sr As New System.IO.StreamReader("demo.txt")
        Dim line As String = String.Empty
        line = sr.ReadLine()

        Do While (Not line Is Nothing)

            If line.Contains(TextBox1.Text) Then
                Label1.Text = c.ToString()
            End If

            line = sr.ReadLine()
            c = c + 1
        Loop

if the item is found then the line number goes to label1..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.