Check is Keys are pressed in KeyDown Event

ryoka012

Active member
Joined
Oct 13, 2011
Messages
32
Programming Experience
Beginner
Hi Guys,

How to know if i enter a text after i press Enter

VB.NET:
    Private Sub RichTextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles RichTextBox1.KeyDown
        If e.KeyCode = Keys.Enter Then
              'check here if i enter a text 
        End If
    End Sub

Thanks guys,
 
Hi jmcilhinney,


thanks for the reply.

sorry for the confusion, but i just want to check if the user press other key after the user press the enter key.

Scenario

On the first line the user does not press the enter key until on the third line.
And check if the user type a letter after the user press the enter key.
Or the user will continue to press the enter key without typing any letter.


thanks and best regards.
 
That sounds like an awful lot of overhead, why do you need a richtextbox and keeping tabs on carrot lines?
 
Hi juggalobrotha,

Yup, the reason for that is to count all the lines.
With the exception of the lines which are empty.
 
to count all the lines.
With the exception of the lines which are empty.
Dim nonEmptyLineCount = Me.RichTextBox1.Lines.Count(Function(line) line.Length > 0)
 
Hi juggalobrotha,

Yup, the reason for that is to count all the lines.
With the exception of the lines which are empty.
In future, please lead with what you're trying to achieve rather than how you're trying to achieve it. There's no point our helping you do something that's a bad idea in the first place. If we know why you're trying to do what you're trying to do, we can let you know whether it's actually worth trying to do it or whether there's something else you should be trying instead.
 
Hi jmcilhinney,

Sorry for the confusion.
And thanks you for reminding me.

Will do it in the future.


Hi JohnH,


Thank you for the code.It Works.
 
Back
Top