Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

[RESOLVED] Determining the End of line....

$
0
0
I have a code here that selects a particular string inside a richtextbox

Dim a As String
Dim b As String
Dim c As String

a = TextBox1.Text
b = InStr(TextBox2.Text, a)
If b Then

TextBox2.SelectionStart = b - 1
TextBox2.SelectionLength = Len(a)
c = textbox2.SelectedText
Else
MsgBox("No text Found!")
End If

My question is how can I tweak it into selecting the whole line of the rich text box?

For instance I have 3 lines

This is my first line
Second one is much longer
The Third one should be the longest

then I searched the word "second", how can I select the whole second line? Because if you use the code above it only gets the word "second" but not the whole line

Thanks in Advance and more powers!

EDIT
By the way, I tried doing TextBox2.SelectionLength = Len(a) + number however of course that works only if you know the exact number of characters, and that wouldnt work since the text generated can be random

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>