Click to See Complete Forum and Search --> : creating a backspace command button


MonaVohra
03-20-2007, 07:50 PM
i am trying to create a button so that when it is clicked it removes the values ina textbox one by one from right to left. i have done this:

Private Sub Button38_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button38.Click
If Len(TextBox1.Text) > 0 Then
TextBox1.Focus()
TextBox1.Text = " "
End If

But this removes all of the values in the textbox. How can the values be removed one by one each time the button is clicked?

Phil Weber
03-20-2007, 08:13 PM
What do you mean by "values?" Do you want to remove one character at a time from the end of the string? If so, try this:

With TextBox1
.Text = .Text.Remove(Len(.Text) - 1, 1)
End With

MonaVohra
03-20-2007, 08:16 PM
yes i meant from the end of a string. thanks :)