Find Last instance of carriage return In a Memo Field


G

Guest

Hi,

I have a form where the user usually pastes a glob of text into it a memo
field called "Comment". After he pastes the text, the cursor is obviously at
the end of the text. I would like the user to be able to click a button and
for the comment to be highlighted from the very end of the text to the first
instance of a carriage return going backwards. In other words, I want to
automatically select the very last line of the comment.



I was thinking that I could use seldown, but I would need to first find the
Last instance of Chr$(13). Or, can the instr function can be used in
reverse, meaning to search the string starting from the end of the line?

Thanks, in advance.
 
Ad

Advertisements

J

John W. Vinson

I was thinking that I could use seldown, but I would need to first find the
Last instance of Chr$(13). Or, can the instr function can be used in
reverse, meaning to search the string starting from the end of the line?

In A2002 and later, there is an InStrRev() function which does just this:

Me!txtboxname.SelStart = InStrRev(Me!txtboxname, vbCrLf)

John W. Vinson [MVP]
 
Ad

Advertisements


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

Top