Link to home
Start Free TrialLog in
Avatar of formadmirer
formadmirerFlag for United States of America

asked on

Text Insert with VFP 9

Hi all. I've been trying to get insertion to work within a text box, so that user input text will be inserted at the current cursor position.

For example we have two textboxes. Textbox 1 is pulled from a db and contains the string "This is what is all about"

Textbox 2 allows user input and the user types the word 'life'

User clicks within textbox 1 to set the cursor position after the word 'what'

By clicking a command button, I would like 'life' to be inserted at the current cursor position, to make the sentence read "This is what life is all about."

This is just an example as the actual text lengths will vary in use.

I've been working with SelStart and I can get the text inserted at the end of the sentence, but not within the body of it. Can someone please help?
ASKER CERTIFIED SOLUTION
Avatar of GreatSolutions
GreatSolutions
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of formadmirer

ASKER

Thanks for the reply. I continued working with it since I posted and was able to get it to insert the text where I wanted. Different than what you posted, but it works.

The only thing is it needs to advance the cursor to the end of the entire text so the user can continue typing.

Any idea how to insert the cursor - or advance the cursor - to a predetermined point?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks all - got it using a conglomeration of SUBSTR and LENs

Points for taking the time to help - I do appreciate it.
I ended up getting this on my own - no fault of the experts - it's just I was working as I posted and eventually got it.
to move cursor use

ThisForm.txtBox1.SelStart =len(alltrim(ThisForm.txtBox1.value))