Private Sub RichTextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
Dim posInLine As Integer = RichTextBox1.SelectionStart - RichTextBox1.GetFirstCharIndexOfCurrentLine()
If e.KeyCode = Keys.Enter Then ' PRESS ENTER KEY TO GOTO NEXT LINE
Button1.Top = Button1.Top + 13 ' BUTTON FOLLOWS RTB CARET (KIND OF)
ToolStripLabel2.Text = RichTextBox1.Lines.Length ' DISPLAYS THE LINE NUMBER IN RTB
End If
If e.SuppressKeyPress = (e.KeyCode <> Keys.Back And e.KeyCode <> Keys.Delete) Then ' BACKSPACE KEY PRESSED
Button1.Top = Button1.Top - 13 ' I NEED THIS TO ONLY MOVE BUTTON UP AFTER THE CURSOR REACHES LEFT MARGIN - THIS BIT DOESN'T WORK VERY WELL
ToolStripLabel2.Text = RichTextBox1.Lines.Length
End If
If ToolStripLabel2.Text < "1" Then ' IF REACH TOP OF RTB, THEN STOP
Button1.Top = 40
ElseIf ToolStripLabel2.Text > "22" Then
Button1.Top = 316 ' IF REACH BOTTOM OF RTB, THEN STOP -~ THIS BIT
End If
End Sub
vbproj.png
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE