• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2694
  • Last Modified:

Virtual touch screen keyboard,I need help with backspace vb.net

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
0
tentavarious
Asked:
tentavarious
1 Solution
 
AlexFMCommented:
Me.txtmessage.Text = Me.txtmessage.Text.Substring(0, Me.txtmessage.Text.Length - 1)
0
 
jrschererCommented:
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

Jack.net
0
 
tentavariousAuthor Commented:
Thanks, thats what I was looking for.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now