Results 1 to 6 of 6

Thread: VB6 code to VB.net .Selstart and .SelLength

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    2

    VB6 code to VB.net .Selstart and .SelLength

    Here is some code I use to high light a textbox when a user needs to re-enter data into a textbox, it works great in vb6 but not in .Net. Does anyone know what methods I would use in .Net to preform the same action.

    txtname.Setfocus
    txtname.Selstart = 0
    txtname = Len(txtName.Text)



    Thanks

    Brad
    SLC, Utah

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Its pretty much the same



    txtName.SetFocus
    txtName.SelectionStart = 0
    txtName.SelectionLength = Len(txtName.Text)

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    2
    Thanks, That's what I was looking for.

    Brad

  4. #4
    Junior Member
    Join Date
    Sep 2002
    Posts
    23
    Now there is .TextLength so you do not need to extract the text to a string just to get the length. The temporary string just has to be garbage collected later.

  5. #5
    New Member
    Join Date
    May 2012
    Posts
    8

    Re: VB6 code to VB.net .Selstart and .SelLength

    What is the difference between GotFocus and setFocus?

  6. #6
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: VB6 code to VB.net .Selstart and .SelLength

    Quote Originally Posted by VbNat View Post
    What is the difference between GotFocus and setFocus?
    You realise this topic is 10 years old? You should start a new thread for any questions you have.

    In any case: GotFocus is an event that you subscribe to.. SetFocus is a method you call.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

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