Virtual touch screen keyboard,I need help with backspace

Posted on 2006-05-22
Last Modified: 2008-01-09
Hello experts,  I created a simple virtual keyboard,  that sends the button text to a textbox.  For example if the A button is pressed, "A" will show up in the textfield.  And if Enter is pressed I send vbcrlf.  I am having trouble with the backspace button,  how do I clear one character in the textfield when backspace is checked?

  Sub filltext(ByVal charval As String)
        Me.txtmessage.Text += charval
    End Sub

    Private Sub btnz_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnz.Click
        filltext(btnz.Text) 'sends a z to the txtmessage
    End Sub

    Private Sub bntenter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntenter.Click
        filltext(vbCrLf) 'sends a line break
    End Sub

 Private Sub bntback_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntback.Click
'What do I put here to clear out one character in the textfield
    End Sub
Question by:tentavarious
    LVL 48

    Expert Comment

    Me.txtmessage.Text = Me.txtmessage.Text.Substring(0, Me.txtmessage.Text.Length - 1)
    LVL 9

    Accepted Solution

    Hi tentavarious

    Try this
    Private Sub bntback_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntback.Click
          If Me.txtmessage.Text.Lenght > 0 Then
                Me.txtmessage.Text = me.txtmessage.Text.Substring(0, Me.txtmessage.Text.Length - 1)
          End If
    End Sub

    Author Comment

    Thanks, thats what I was looking for.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now