Detecting Carriage Return

  • Thread starter Thread starter pregis
  • Start date Start date
P

pregis

Hi.. How would I tell a text box that once the user presses enter in the text
box that the text in the text box is cleared and it is moved into a rich
text box?
 
pregis said:
How would I tell a text box that once the user presses enter in the text
box that the text in the text box is cleared and it is moved into a rich
text box?

Add a button to the form and assign it to the form's 'AcceptButton'
property. Make sure there is no 'DialogResult' assigned to the button in
the properties window. Then add the code to transfer the text to the
richtextbox and to clear the textbox to the button's 'Click' event handler.
 
Add a button to the form and assign it to the form's
'AcceptButton' property. Make sure there is no
'DialogResult' assigned to the button in the properties
window. Then add the code to transfer the text to the richtextbox and to
clear the textbox to the button's
'Click' event handler.

.. . . erm, Hello? Anybody there? The OP asked, "How would I tell a text box
that once the user presses enter /in
the text box/ . . . etc". Your 'solution' would result in the action being
taken when the user pressed Enter whether he was in the textbox or not! We
keep getting told by the various dotnet evangelists who from time to time
infest the VB6 newsgroup that we VB6 programmers are stupid dinosaurs and
that VB.Net programmers are the clever people. I can't yet see much
evidence of that ;-)

Mike
 
Hi.. How would I tell a text box that once the user presses enter in the text
box that the text in the  text box is cleared and it is moved into a rich
text box?

Check the e.KeyCode property in the KeyUp event handler for the
textbox and process the textbox's Text property accordingly.
 
Mike Williams said:
. . . erm, Hello? Anybody there? The OP asked, "How would I tell a text
box that once the user presses enter /in
the text box/ . . . etc". Your 'solution' would result in the action being
taken when the user pressed Enter whether he was in the textbox or not!

That's true. I was thinking about somethink like a chat application or a
dialog which enables the user to add items to a "list".
 
Perhaps as simple as:

Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
If e.KeyCode = Keys.Enter Then
RichTextBox1.Text = TextBox1.Text
TextBox1.Text = ""
End If
End Sub

Dick

--
Richard Grier (Microsoft MVP - Visual Basic) Hard & Software 12962 West
Louisiana Avenue Lakewood, CO 80228 303-986-2179 (voice) Homepage:
www.hardandsoftware.net Author of Visual Basic Programmer's Guide to Serial
Communications, 4th Edition ISBN 1-890422-28-2 (391 pages) published July
2004, Revised July 2006.
 
No the clever ones are those using C# ;-)


Mike Williams said:
. . . erm, Hello? Anybody there? The OP asked, "How would I tell a text
box that once the user presses enter /in
the text box/ . . . etc". Your 'solution' would result in the action being
taken when the user pressed Enter whether he was in the textbox or not! We
keep getting told by the various dotnet evangelists who from time to time
infest the VB6 newsgroup that we VB6 programmers are stupid dinosaurs and
that VB.Net programmers are the clever people. I can't yet see much
evidence of that ;-)

Mike
 
That is perfect! Thank you so much and a big thank you to EVERYONE that
replied... I really appreciate it.
 
Back
Top