473,382 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to get the starting and end character position of the given line no in RichTextBox


Hi All,

How to get the starting and end character position of the given line no in
RichTextBox?
I have written following code but it takes more time.
Is there any RichTextBox function or API function which gives that?

Private Sub SetLineStartEndPosition(ByVal myRichTextBox as RichTextBox,
ByVal LineNo As Integer, ByRef StartPosition As Integer, ByRef EndPosition
As Integer)
Dim intCurrentLine As Integer
Dim intCurrentPosition As Integer
StartPosition = -1
EndPosition = -1
With myRichTextBox
For intCurrentPosition = 0 To .TextLength
If StartPosition = -1 And LineNo =
..GetLineFromCharIndex(intCurrentPosition) Then
StartPosition = intCurrentPosition
End If
If EndPosition = -1 And LineNo <
..GetLineFromCharIndex(intCurrentPosition) Then
EndPosition = intCurrentPosition - 1
Exit For
End If
Next
If EndPosition = -1 Then
EndPosition = .TextLength - 1
End If
End With
End Sub

Any help will be appreciated.
Thanks in Advance

Sakharam Phapale
Nov 21 '05 #1
0 1478

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris | last post by:
Using VB6. With a RichTextbox, I can get the position of the character under the mouse pointer with an API call like: SendMessage(hWnd, EM_CHARFROMPOS, 0&, Pointl) by passing the mouse x,y...
3
by: GSX | last post by:
I've been reading and searching (and searching and reading) for far too many hours. I'm rather new - so I apologize if this is an over asked question... I'm working on a small text editor as a...
2
by: Just Me | last post by:
I insert text in a RichTextBox ending each line with vbCrLf. I think when I search the RichTextBox text I do not find any CR's. In the Text property is the end of line char a LineFeed? Are...
2
by: Al | last post by:
Hi, Is there any way to replace a character at a position? Without cussing the RichTextBox to scroll. For example the following code will replaces the by removing but the side effect is that it...
0
by: John Smith | last post by:
I have text files and I get binary offsets of text portion of these files from VB6 program with RichTextBox. I use VB.Net 2003 and need to select and highlight the text between given offsets....
2
by: gsb58 | last post by:
Hi! I'm new to VB.NET Anybody that could show me how to find the cursor position in a RichEdit? That is: when user click anywhere in the box and there's some text already, I want to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
11
by: Gustaf | last post by:
Some error handling code: catch (System.Xml.XmlException e) { Console.WriteLine("Error in " + e.SourceUri + ": " + e.Message); return; } The output:
5
by: Andrus | last post by:
I use Winforms RichTextBox control to edit scripts. Scripts are plain ascii texts. When error occurs, script engine returns character position of error in code as integer. How to position...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.