Solved

VB RichText Box

Posted on 1998-09-14
4
353 Views
Last Modified: 2008-02-01
Ok, I have a RichText Box and I want to locate the Current Row and Column.

Row (Line number) is: RT.LineFromChar(RT.SelStart)

What is the Col (Current Character Position)?  It is not RT.SelStart
0
Comment
Question by:MasseyM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1434908
Create a loop For..next loop  between the first character and the current character...Using the GetlinefromChar locate the first character in that lines position ... subtract and thats the column value.... Oh and getLinefromchar is the row....

If you need full code... Suggest you increase the points.....But I'll have a look.....


 
0
 
LVL 10

Author Comment

by:MasseyM
ID: 1434909
I want full code... I have the points...

BTW, this must be on-the-fly... I am not sure a loop will work...

0
 
LVL 1

Accepted Solution

by:
MAVERICK earned 50 total points
ID: 1434910
' Declarations

Dim Row As Long
Dim Col As Long
Dim A As Long
Dim B As Long
Dim C As Long
Dim D As Long
'Code for actual position finding
'The Richtext box is the one you want the position for
' Row & column are the co-ordinates
' the text boxes are for testing only


Private Sub RichTextBox1_SelChange()

A = RichTextBox1.SelStart
D = A

B = RichTextBox1.GetLineFromChar(RichTextBox1.SelStart)
If B = 0 Then
Row = 0
Col = A
Else
Do Until RichTextBox1.GetLineFromChar(A - 1) = B - 1
A = A - 1
Loop
Row = RichTextBox1.GetLineFromChar(A + 1)
Col = D - A
End If
Text3.Text = Row
Text4.Text = Col
End Sub

Have fun.....
Jon

0
 
LVL 10

Author Comment

by:MasseyM
ID: 1434911
Maverick!  Marvelous job... Exactly what I wanted...

I have about 200 points waiting to be returned... I will post a question in what ever category you wish as soon as I get my points back...

Just tell me where (I will give another 150).

Thanks!

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question