Consulting

Results 1 to 14 of 14

Thread: highlight all text in textbox - only fix

  1. #1

    highlight all text in textbox - only fix

    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.

    [vba]
    With DovodOM1
    .SelStart = 0
    .SelLength = 500
    EnterFieldBehavior = fmEnterFieldBehaviorSelectAll
    End With
    [/vba]
    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try the DovodOM1_Enter event.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    ok,
    this Enter event stops (with mark braun) but it also doesnt highlight text.

    this code i use
    [VBA]
    Private Sub DovodOM1_Enter()
    DovodOM1.SelStart = 0
    DovodOM1.SelLength = 500
    End Sub
    [/VBA]

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    [VBA]Private Sub DovodOM1_Enter()
    With DovodOM1
    .SelStart = 0
    .SelLength = Len(.Text)
    End With
    End Sub[/VBA]

  5. #5
    Quote Originally Posted by Kenneth Hobs
    [vba]Private Sub DovodOM1_Enter()
    With DovodOM1
    .SelStart = 0
    .SelLength = Len(.Text)
    End With
    End Sub[/vba]
    the same effect...only edit existing text in textbox.
    What can be wrong?

  6. #6
    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

  7. #7
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Post a workbook as it works for me.

  8. #8
    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.

  9. #9
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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.

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    Last edited by Bob Phillips; 09-29-2011 at 12:52 AM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    I enter the Kenneth's code in the MouseDown event and it works like a charm.

  12. #12
    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...
    Attached Images Attached Images

  13. #13
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Obviously, you must be changing the Visible property to True at some point.

  14. #14
    Quote Originally Posted by Kenneth Hobs
    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....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •