ok, so I have a button thst I want to use to take the cursor
in a RichText Box from where ever it is in the box, to the beginning of the test in the box, how could I do that?
Printable View
ok, so I have a button thst I want to use to take the cursor
in a RichText Box from where ever it is in the box, to the beginning of the test in the box, how could I do that?
do you mean the mouse cursor or the flashing cursor in the rtb?
code for setting flashing cursor pos in rtb
Code:Private Sub Text1_GotFocus()
RTB1.SelStart = 0
End Sub
Use the RichTextBox's SelStart property and then set focus to it:
Code:RichTextBox1.SelStart = 0
RichTextBox1.SetFocus
code to randomize the cursor's position
Code:'in a module
Declare Function SetCursorPos Lib "user32.dll" (ByVal x As Long, ByVal y As Long) As Long
'wherever
Dim myX As Integer
Dim myY As Integer
Randomize
myX = Int(600 * Rnd)
myY = Int(600 * Rnd)
Debug.Print myX & ":" & myY
retval = SetCursorPos(myX, myY)
Quote:
Originally posted by Matthew Gates
Use the RichTextBox's SelStart property and then set focus to it:
Code:RichTextBox1.SelStart = 0
RichTextBox1.SetFocus
bad luck, beat you by two minutes