Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Edit box focus

Edit box focus

Scheduled Pinned Locked Moved Visual Basic
questioncom
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Red Sunday
    wrote on last edited by
    #1

    I have an edit box called Login. How do I set the focus on Login at THE END of the string currently in Login? calling Login.SetFocus sets the cursor at the beginning of the string. I want it at the end. Thank you, Red Sunday ----------------- http://www.zachcalvert.com

    M L 2 Replies Last reply
    0
    • R Red Sunday

      I have an edit box called Login. How do I set the focus on Login at THE END of the string currently in Login? calling Login.SetFocus sets the cursor at the beginning of the string. I want it at the end. Thank you, Red Sunday ----------------- http://www.zachcalvert.com

      M Offline
      M Offline
      MohammadAmiry
      wrote on last edited by
      #2

      Try: TextBox1.SelectionStart= TextBox1.Text.Length TextBox1.Focus()

      1 Reply Last reply
      0
      • R Red Sunday

        I have an edit box called Login. How do I set the focus on Login at THE END of the string currently in Login? calling Login.SetFocus sets the cursor at the beginning of the string. I want it at the end. Thank you, Red Sunday ----------------- http://www.zachcalvert.com

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Try this code:

        With txtLogin
            .SelStart = 0
            .SelLength = Len(.Text)
            .SetFocus
        End With
        

        A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

        M 1 Reply Last reply
        0
        • L Lost User

          Try this code:

          With txtLogin
              .SelStart = 0
              .SelLength = Len(.Text)
              .SetFocus
          End With
          

          A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

          M Offline
          M Offline
          MohammadAmiry
          wrote on last edited by
          #4

          Hi First I'm sorry because I wrote the code for C# and not for VB.NET!:rolleyes:;P I think the code you wrote for answering Red's problem, that will also select the whole text of the textbox, is not what Red was looking to. The correction to your code (If my guess in the problem is correct) is this: With txtLogin .SelLength = 0 .SelStart = len(.Text) .SetFocus End with code>

          L 1 Reply Last reply
          0
          • M MohammadAmiry

            Hi First I'm sorry because I wrote the code for C# and not for VB.NET!:rolleyes:;P I think the code you wrote for answering Red's problem, that will also select the whole text of the textbox, is not what Red was looking to. The correction to your code (If my guess in the problem is correct) is this: With txtLogin .SelLength = 0 .SelStart = len(.Text) .SetFocus End with code>

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Oh, thank you very much for your information. Because I did not look the question carefully that make me confuse. Thank you very much that you correct my mistake :-O


            A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups