Results 1 to 4 of 4

Thread: [RESOLVED] Textbox how do I invert-select the text?

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2008
    Posts
    265

    Resolved [RESOLVED] Textbox how do I invert-select the text?

    Hi, can anyone please help me on this. I have no idea of how I would code it to select a text in a textbox BUT the cursor must end at the selstart position. How do I do this?? Please help me.. Thanks a lot!

    PS: I attached the screenshots for both the unwanted and wanted condition.
    Attached Images Attached Images   

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Textbox how do I invert-select the text?

    this may do ur wish, add a cmd butn and textbox
    Code:
    Private Sub Command1_Click()
    Text1.SetFocus
    Text1.SelStart = 10 'starting position
    SendKeys "+{LEFT 5}" 'shift + left arrow 5 times
    End Sub
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Textbox how do I invert-select the text?

    Code:
    Private Sub Form_Load()
        Dim MyArray() As String, i As Integer, j As Integer
        
        '~~> Sample Text
        Text1.Text = "Testing Words"
        
        '~~> Split Text "space" as delimiter
        MyArray = Split(Text1.Text, " ")
        
        '~~> Moving the cursor to the end of the text
        Text1.SelStart = Len(Text1.Text)
        
        '~~> Deciding the number of Chars to move backwards
        j = Len(MyArray(UBound(MyArray)))
        
        '~~> Move backwards...
        For i = 1 To j
            SendKeys "+{Left}"
        Next i
    End Sub
    Edit: Damn... I am late... seenu_1st has already replied...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2008
    Posts
    265

    Re: Textbox how do I invert-select the text?

    Oh my greatness! Just that easy! Hey thanks guys

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