|
-
September 17th, 1999, 10:31 PM
#1
selecting text in textbox, something different
Hi everyone,
I am looking for a way to select text in a text box without having to put this
Text1.SelStart = 0
Text1.SelLength = Len(Text1)
into every textbox focus event. I have over a one hundred textboxes. That is a lot. Sure I could put it in a public sub and then call that in every focus event but still the same inherent problem - - 100+ textboxes. whehh. I am looking instead for something that only has to be declared once when the form loads. I am new to this. I guess it would be some kind of API call?
Any help or direction would be great. Thanks
Harold
-
September 18th, 1999, 09:59 AM
#2
Re: selecting text in textbox, something different
Even if you did use an API call (check the SDK for the text control) you would still have to call it a hundred times. You can set them all nearly at once by iterating through the form's??
controls collection then use a statement like 'If TypeOf cntrl Is Textbox then ' and insert your code you posted here.<==not sure if it would work but trying to give you some ideas...
-
September 18th, 1999, 10:18 AM
#3
Nevermind, Dumb idea
The textbox has to have focus to have its text selected, just tried it out. Doh!
-
September 18th, 1999, 10:47 AM
#4
Re: selecting text in textbox, something different
write the code(as u mentioned Above) in the gotfocus event and made this an activex control use it anywhere
-
September 18th, 1999, 02:21 PM
#5
Control Array's
If you make your Textboxes into a Control array (Give all your Textboxes the same name) then you can Select your TB's text like this.
For A = 0 to 99
Text(A).SelStart=1
Text(A).SelLength=5
Next
And That's a WHOLE Lot simpler than doing 100's of those statements... (But you'll have to Rename/Remake your TB's (Textboxes)
-Ximmer
-
September 18th, 1999, 04:27 PM
#6
Re: selecting text in textbox, something different
Mikesc,
Thanks. Yes, 'If typeof control is textbox' works. Only have to call that function with one line. That is what I had decided to do after I posted. I had contempleated the idea before but thought I would still see if possible another way. However, Ximmer had a great idea bout making all the textboxes a control array. I think that could be useful. 'preciate the help
Harold
-
September 19th, 1999, 09:54 AM
#7
Re: selecting text in textbox, something different
Sorry about my lapse of judgement yesterday. Ximmer's idea would work but not the code. If you got the textbox array set up, just put your code in the GotFocus event. It'll select the text in any textbox in the array, when, of course, the box enters focus.
-
September 19th, 1999, 11:52 AM
#8
Re: selecting text in textbox, something different
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|