Results 1 to 3 of 3

Thread: Setfocus troubles

  1. #1

    Thread Starter
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375

    Exclamation Setfocus troubles

    MY setfocus function had been acting wierd and i was wondering if anyone else has encountered this problem. In my program,when a user enters incorrect data, it deletes the data in that textbox and then i do this
    VB Code:
    1. text1.setfocus

    It deletes the current text fine but then set's the focus on the textbox below the one i put in the code. It also put the mouse on highlight so hen i move the mouse, it highlights whatever's in the lower textbox. It's not a huge problem but is annoying, could anyone help?
    -Show me on the doll where the music touched you.

  2. #2
    Hyperactive Member Tequila_worm's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    344
    What i do when a user enters incorrect info is just highlight the text for the user. But i had never experienced any problems such as the ones you are mentioning. This is how i do it.


    In Module

    VB Code:
    1. Public Function Highlight(oTxt As Object)
    2.     oTxt.SetFocus
    3.     oTxt.SelStart = 0
    4.     oTxt.SelLength = Len(oTxt.Text)
    5. End Function

    In Form

    VB Code:
    1. 'This is how you would call it
    2.  
    3. Private Sub cmdBla_Click()
    4.  
    5.    Call Highlight(txtWhatEver)
    6.  
    7. End Sub


    Hope this helps

  3. #3

    Thread Starter
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    That is quite a good idea , Thanks. I think that would look better than my old method. I just noticed that that involves setfocus and since mine is on the fritz, it still won't fix it.
    -Show me on the doll where the music touched you.

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