Results 1 to 3 of 3

Thread: [RESOLVED] [2008] Backspace in Code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Resolved [RESOLVED] [2008] Backspace in Code

    Lets sat we have a textbox with text (Textbox1.Text)
    if we click backspace the last character will be removed
    but if the last character was a New Line (Enter), 2 characters would be removed...
    I need help puting this in code
    Code:
        Private Sub BackSpace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackSpace.Click
    
        End Sub

  2. #2
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: [2008] Backspace in Code

    How's this?

    Code:
    TextBox1.Text = TextBox1.Text.Remove(TextBox1.Text.Length - 1, 1)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Backspace in Code

    vb.net Code:
    1. If myTextBox.Text.EndsWith(Environment.NewLine) Then
    2.     'Remove two characters.
    3. Else
    4.     'Remove one character.
    5. End If
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width