Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,381 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,328 people online right now. Registration is fast and FREE... Join Now!




Delete a Line From a Textbox?

 
Reply to this topicStart new topic

Delete a Line From a Textbox?

Ameel
17 Sep, 2008 - 05:35 AM
Post #1

D.I.C Head
**

Joined: 19 Jun, 2008
Posts: 91



Thanked: 2 times
My Contributions
Hi. I have a Textbox.

What I want is that when someone types into the textbox1, and presses "enter", the data of the textbox1 is transfered to the textbox2.

However, my code does not work properly, since when the person presses "enter", this is recorded as data of the textbox1 as well. I do not want that extra line. (So, I need to delete it, right?)

Please help.

CODE


    Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
        PressEnterInTextbox(sender, e)
    End Sub


    Public Sub PressEnterInTextbox(ByVal sender, ByVal e)
        If e.KeyCode = Keys.Enter Then
            textbox2.text = textbox1.text
        End If


User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Delete A Line From A Textbox?
17 Sep, 2008 - 06:05 AM
Post #2

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,063



Thanked: 17 times
Dream Kudos: 950
My Contributions
In the TextBox_KeyDown() event type this
vb

Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
TextBox2.Text = TextBox1.Text
e.SuppressKeyPress = True
End If
End Sub


Hope this helps

This post has been edited by gbertoli3: 17 Sep, 2008 - 06:06 AM
User is offlineProfile CardPM
+Quote Post

Ameel
RE: Delete A Line From A Textbox?
17 Sep, 2008 - 06:23 AM
Post #3

D.I.C Head
**

Joined: 19 Jun, 2008
Posts: 91



Thanked: 2 times
My Contributions
QUOTE(gbertoli3 @ 17 Sep, 2008 - 07:05 AM) *

In the TextBox_KeyDown() event type this
vb

Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
TextBox2.Text = TextBox1.Text
e.SuppressKeyPress = True
End If
End Sub


Hope this helps


Shit. Sorry. I sux.

Yah. On keydown its perfect. Problem is on keyup which i was using. Awesome man. Thanks for that. You are sexy!

Cheers

This post has been edited by Ameel: 17 Sep, 2008 - 06:29 AM
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Delete A Line From A Textbox?
17 Sep, 2008 - 06:30 AM
Post #4

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,063



Thanked: 17 times
Dream Kudos: 950
My Contributions
OK to suppress the enter key, but have it only in one TextBox
vb

Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
End If
End Sub


Hope this helps

This post has been edited by gbertoli3: 17 Sep, 2008 - 06:38 AM
User is offlineProfile CardPM
+Quote Post

Ameel
RE: Delete A Line From A Textbox?
17 Sep, 2008 - 06:37 AM
Post #5

D.I.C Head
**

Joined: 19 Jun, 2008
Posts: 91



Thanked: 2 times
My Contributions
QUOTE(gbertoli3 @ 17 Sep, 2008 - 07:30 AM) *

OK Try this
vb

Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
End If
End Sub


Hope this helps


EDIT: Did you change your post?


Yes I did. Sorry. You're orsm! Wuv u hard! XD
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:48PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month