Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Position of the cursor in a text box

Status
Not open for further replies.

WyoProgrammer

Technical User
May 13, 2005
25
0
0
US
I have a text box that I am using for input in a recipe program I have written. I need to determine where the cursor is in the text box so I can insert characters when editing the text string. I have done a search and apparently this is possible in later editions of VB but I am using version 5. Not sure how this is done or if it is even possible with a work-around. Any suggestions?
 
>need to determine where the cursor (caret) is in the text box
See/ examine/ set the SelStart and SelLength Properties of the TextBox. For the deets look up SelStart and SelLength in vb help.
SelText may be handy too.
 
The 'Sel' Properties are supported in vb6, I hope you'll find them in vb5.
 
I read something about the SelStart and SelLength properties and checked but VB5 does not have them. Is there a work-around that you know of?
 
>but VB5 does not have them

Er ... it's been a while since I used VB5, but I'm pretty certain that it has all the various Sel properties for the textbox. And this is supported by the documentation. For example:

VB5 Programmers Guide said:
Selecting Text
You can control the insertion point and selection behavior in a text box with the SelStart, SelLength and SelText properties
 
I looked at the properties box in the editor and saw nothing about it but will play around with these properties and see if I come up with something. Thanks!
 
I just went and checked it out and these properties are selectable in the programming window when I type a period at the end of my txtList. designation. I was able to determine the cursor position and also insert a character at that position so you have answered my question. I had worked on this for several days and now have my solution. What I was trying to do was to insert a special character like the degree symbol, 1/4, 1/2, 3/4 as single characters for a recipe program I am working on. Thanks for leading me in the right direction!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top