Find position of cursor in text box

  • Thread starter Adrian D. Bailey
  • Start date
A

Adrian D. Bailey

Is there a way I can determine the position of the cursor in a text box in a
custom form?

Reason - if the user has just typed a CR/LF I want the macro to add in a
bullet point.
I've made this happen when the cursor is at the end of the text by putting
the following in an On Change macro
if right(mytext,2) = chr(13) & chr(10) then mytext = mytext & chr(149) &
chr(32)
but I'm struggling for a method that works when the cursor is in the middle
of the text.

--
Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences
Loughborough University, Loughborough Leics, LE11 3TU, UK.
(e-mail address removed) Tel: 01509 223007 Fax: 01509 223940

Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509 563263
--
 
J

Jim Rech

SelStart should do it if I understand you.

Private Sub TextBox1_Change()
Debug.Print TextBox1.SelStart
End Sub


--
Jim
| Is there a way I can determine the position of the cursor in a text box in
a
| custom form?
|
| Reason - if the user has just typed a CR/LF I want the macro to add in a
| bullet point.
| I've made this happen when the cursor is at the end of the text by putting
| the following in an On Change macro
| if right(mytext,2) = chr(13) & chr(10) then mytext = mytext & chr(149) &
| chr(32)
| but I'm struggling for a method that works when the cursor is in the
middle
| of the text.
|
| --
| Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences
| Loughborough University, Loughborough Leics, LE11 3TU, UK.
| (e-mail address removed) Tel: 01509 223007 Fax: 01509 223940
|
| Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509
563263
| --
|
|
 
A

Adrian D. Bailey

Thanks Jim, just what I was looking for.

--
Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences
Loughborough University, Loughborough Leics, LE11 3TU, UK.
(e-mail address removed) Tel: 01509 223007 Fax: 01509 223940

Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509 563263
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Network Username 2
Can't launch Internet Explorer 1
Rounded Rectangle 3
Getting started 1
Problem with Network Latency 2
When to use With - End With? 3
What's this new sheet? 6
Speed this up for me, please 1

Top