Results 1 to 6 of 6

Thread: I need Help

  1. #1

    Thread Starter
    Lively Member israr's Avatar
    Join Date
    May 2001
    Posts
    73

    I need Help

    how to set the cursor position in a text box control.
    Private Sub VBForums_Newthread()
    If Thread.Question = Hard then
    MSGBox "No one can reply..."
    Else If Thread.Question=Easy then
    Print "It's very easy.."
    MsgBox "God helps those who helps themselves."
    End If
    End sub

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    If you mean to set the focus to the text box then use
    Code:
    Textboxname.SetFocus
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    But if you mean the mouse cursor then
    Code:
    Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long
    
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    
    Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long
    
    'somethin like this
    Dim r as RECT
    GetWindowRect text1.hwnd,r
    SetCursorPos r.left + (text1.width /2),r.top + (text1.height/2)
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    Lively Member israr's Avatar
    Join Date
    May 2001
    Posts
    73
    no to change the cursor position within the textbox
    Private Sub VBForums_Newthread()
    If Thread.Question = Hard then
    MSGBox "No one can reply..."
    Else If Thread.Question=Easy then
    Print "It's very easy.."
    MsgBox "God helps those who helps themselves."
    End If
    End sub

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    You can use
    Code:
    Private Sub Form_Click()
    SendKeys "{RIGHT}", True
    End Sub
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  6. #6
    Megatron
    Guest
    Or just change the SelStart property of the TextBox.
    Code:
    Text1.SelStart = 10

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