I am searching for a string in a textbox in my web application. My output must be the line number of where the string can be found in the textbox.
To find the string in the textbox i am using IndexOf (which helps me make sure if the string is in the textbox or not). I know that if the string is in the textbox it will give me the number of characters as to where the string is.
Now is there a way of finding the line number???
(I was thinking that i go through the textbox starting from the first character all the way to string and as i pass by i check if there is a newline, but i dont know how to check if there is a new line in a textbox)
mjzammit
0
Newbie Poster
Recommended Answers
Jump to PostSplit the text in the TextBox by '\n' search for each index in output array in the string and by refering to index you got the line number
i.e
You were my strength when I was weak
You were my voice when I couldn't speak
You were my eyes …
Jump to PostSplit a string method not TextBox Method
so TextBox1.Text.Split(....)
All 7 Replies
Ramy Mahrous
401
Postaholic
Featured Poster
mjzammit
0
Newbie Poster
Ramy Mahrous
401
Postaholic
Featured Poster
mjzammit
0
Newbie Poster
mjzammit
0
Newbie Poster
mjzammit
0
Newbie Poster
Ramy Mahrous
401
Postaholic
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.