Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get specific line
#1
Hi all!

I have a little question about how to read a line that contains for example "blabla", it's just a part of the text so no complete match.

Thanks in advance! <!-- s8-) --><img src="{SMILIES_PATH}/icon_cool.gif" alt="8-)" title="Cool" /><!-- s8-) -->
#2
You sorta already have an answer in this thread:
<!-- l --><a class="postlink-local" href="http://bpforums.info/viewtopic.php?f=9&t=645">viewtopic.php?f=9&t=645</a><!-- l -->

If we just alter the code a little bit, we can get it to do exactly what you want!
[code2=vbnet]Public Function ReadLine(ByVal containing As String)
If (TextBox1.Text.Contains(containing)) Then
'Now, we need to find which line index contains the thing
Dim lineIndex As Integer = TextBox1.GetLineFromCharIndex(TextBox1.Text.IndexOf(containing))
'Now, let's return the line
Dim lines As New List(Of String)
lines.AddRange(TextBox1.Text.Split(vbNewLine))


Return lines.Item(lineIndex)
End If
End Sub[/code2]

And there you go! Now to get the entire line, you can simply do something like this:
[code2=vbnet]MsgBox(ReadLine("blabla"))[/code2]
My Blog | My Setup | My Videos | Have a wonderful day.
#3
Thanks man, appreciate your help!


Forum Jump:


Users browsing this thread: 1 Guest(s)