Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default User form: select all text on text field entry not working

Rick Rothstein submitted this idea :
I always think of it as String function work with the actual characters
themselves... the first character is position 1... whereas the Selxxx
functions work with the positions between the characters. Just to be clear
about this, the "Sel" in the various Selxxx commands is short for "selection"
(referring to selected text). Picture in your mind some selected
characters... they are highlighted and SelStart and SelLength are used in
code to do the selecting of those characters. Let's work with one character
because it is easy to picture, so SelLength is 1 (but SelLength could be more
which just means more characters are selected). Picturing the selected
character, think where SelStart must be... yep, it is located to the left of
the character that was selected... it acts as the anchor point for the
selection... the highlight starts from the SelStart position immediately to
the left of the selected character and a SelLength of 1 says starting from
that SelStart position, sweep across one character and highlight it. So, to
select the first character, SelStart, the anchor point is located before that
first character, at position 0 (it really has to be 0 because I think things
would break down at the end of the text if it were 1). I don't know if the
above is clear or not, but I think if you keep in mind that the Sel part of
the command is short for "selection", it might help.

Rick Rothstein (MVP - Excel)




"GS" wrote in message ...

It happens that Rick Rothstein formulated :
Try 'SelStart = 1' since 1 is the position of the first character.


No, Garry, 0 is the correct starting point for SelStart... SelStart is the
location of the caret (text cursor) and its starting position is before the
first character which is indexed for it at 0. The help file for SelStart
sort of addresses this in the description section for the Long argument.

Rick Rothstein (MVP - Excel)


Thanks, Rick!
This has always been confusing for me to get right, causing me to
always paly around with it to get the correct result. Your explanation
of the relationship between the caret position and the starting point
clears this up. If I've finally captured the gist of it then starting
point is BEFORE the left side of a particular character position (0
being before 1); start position as used in InStr, for example, is to
the left of the specified character position, based on the 1st
character being 1.


Thanks again, Rick. Not sure if your extended explanation is any more
helpful than the first. I've more or less concluded that the Sel????
functions work with the position BEFORE the character whereas the
String functions work with the position the character is AT in the
string.

The part about Sel meaning 'selection' has always been there for me and
so the position part was what I got confused with. I think it's mostly
because I use the String functions way more than Sel???? and so I've
made a mental "i before e except after c" type of rule: "sel BEFORE pos
AT"!

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic user form question - hjow to write to a text field Mark Stephens Excel Programming 1 March 8th 09 02:29 PM
Highlight/Select text in User Form? Alan Smith Excel Discussion (Misc queries) 2 September 13th 07 09:02 PM
Text box in User Form resizing upon data entry Barb Reinhardt Excel Programming 1 November 8th 06 03:53 PM
how to format a date/validate for a text box entry on a user form Tom Ogilvy Excel Programming 3 June 1st 05 05:06 PM
Validate text box entry on user form Gareth[_3_] Excel Programming 2 November 20th 03 09:59 PM


All times are GMT +1. The time now is 06:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"