Results 1 to 5 of 5

Thread: SelStart And SelLength

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Location
    cornwall, England
    Posts
    110

    SelStart And SelLength

    hi all,
    i have 20 txtboxes where a user has to input a correct answer to a question , if incorrect i want the text to be highlighted
    i have used the code below but only 1 txtbox highlights even if more are incorrect.


    If LCase(Text1) Like LCase("Fred") Then
    lblScore.Caption = lblScore.Caption + 1
    Else
    lblScore.Caption = lblScore.Caption + 0
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    End If

    tink

  2. #2
    Lively Member Ali G's Avatar
    Join Date
    Nov 2001
    Location
    Staines
    Posts
    120
    dat is coz it will only show da highlight on da textbox dat 'as da focus.

    Only one control can 'ave da focus at any one time, aye

    Respect

  3. #3
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    That is becasue you only specified 1 textbox. If you have 20 boxes then you have to do that for each textbox, unless you take my earlier suggestion and make a control array. Then you can do it much easier.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  4. #4
    Lively Member Ali G's Avatar
    Join Date
    Nov 2001
    Location
    Staines
    Posts
    120
    ok, try dis experiment

    Open up any app dat has lots of textboxes, any windoze app. now, what 'appens whun you highlight some text in one of da boxes, ten move da focus elsewhere? would you belive, but da highlight disapears

    it is 'ow windoze works and der is nuffin yous can do abou' it

    respeck

  5. #5
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    You have actually select the text in more than 1 textbox. You'll have to first set the property "HideSelection(or similar)" to false for all the textboxes, then you can either select the text in all the textboxes manually or you can have an array of 20 textbox, and then you just to select the text in a loop.
    Baaaaaaaaah

Posting Permissions

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



Click Here to Expand Forum to Full Width