PDA

View Full Version : highlight all text in textbox - only fix



danovkos
09-27-2011, 05:59 AM
Hi all,
pls. i tried all what i found on net, but nothinghs works.
I try to after clicking on my textbox select/highlight all text in textbox.
I have place this code in Private Sub DovodOM1_click() but after clicking it doesnt call this sub. I know, it because i mark first line of this private sub in debugger with stop(braun circle - i dont know how it calls) and it doesnt call it.


With DovodOM1
.SelStart = 0
.SelLength = 500
EnterFieldBehavior = fmEnterFieldBehaviorSelectAll
End With

This is only part of my big code. In first part i assign to my textbox with name DovodOM1 value. It is a text. Then after clicking on buttons appears my userform. In userform is this textbox, but when i click on my textbox do nothing. Only editing is possible without highlighting text in textbox.

Also i tried insert this code in change Sub, but it doesnt works as i want. If is code there (in change) i can write only first letter.

any suggestions?
thx

Bob Phillips
09-27-2011, 06:02 AM
Try the DovodOM1_Enter event.

danovkos
09-27-2011, 06:13 AM
ok,
this Enter event stops (with mark braun) but it also doesnt highlight text. :(

this code i use

Private Sub DovodOM1_Enter()
DovodOM1.SelStart = 0
DovodOM1.SelLength = 500
End Sub

Kenneth Hobs
09-27-2011, 06:40 AM
Private Sub DovodOM1_Enter()
With DovodOM1
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub

danovkos
09-27-2011, 06:44 AM
Private Sub DovodOM1_Enter()
With DovodOM1
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub

the same effect...only edit existing text in textbox.
What can be wrong?

danovkos
09-27-2011, 06:50 AM
now i figured out, that it works, when i click on border of textbox, but if i click in the midle of tb, than it jump to center of tb and edit it....
is it usual behavior?
i thought, that it highlight text after click to tb not on border of tb

Kenneth Hobs
09-27-2011, 07:04 AM
Post a workbook as it works for me.

danovkos
09-27-2011, 07:39 AM
sorry i really want, but it is not possible.
It is very big file with many of secret data.... :((

i know, now is not possible to figured out, where the problem is. :(

Kenneth Hobs
09-27-2011, 07:46 AM
It is easy to make a userform with a textbox. Half the work in solving a problem is defining it. The mechanic can not always fix your car if you just tell him what is wrong and don't bring the car in.

If your file is that big, you might have something else going on.

Bob Phillips
09-27-2011, 08:00 AM
As Kenneth says, there might be a related problem. Try creating a simple workbook, no secret data, and add a form with that code, and see if it still fails.

rcharters
09-27-2011, 10:28 AM
I enter the Kenneth's code in the MouseDown event and it works like a charm.

danovkos
09-29-2011, 12:33 AM
my userform depend on my data. It works with my data. Load it to userform and base this data set, show, other infos...:(

Because this is for me impossible to send it. But of course i understand, that for you is impossible to solve this strange problem without my file. I will try it by my self.

Only one question. Can be the problem in properties of textbox?
in attach. is all settings of my tb.
thx for all your help...

Kenneth Hobs
09-29-2011, 01:22 AM
Obviously, you must be changing the Visible property to True at some point.

danovkos
09-29-2011, 01:27 AM
Obviously, you must be changing the Visible property to True at some point.

yes, of course, i do this. If is my ID tb not blank, this tb is visible....