I have a backspace key button.
Then I have two text boxes.
Well, it is working but when the letters in a certain text box are all cleared up then i keep on clicking the button I get this errror.
This is the code:
desiredTextbox.Text = desiredTextbox.Text.Substring(0, desiredTextbox.Text.Length - 1)
Then it has this error:
ArgumentOutofRange was unhandled

How am I supposed to do with that?
Thank you for any responses!

Recommended Answers

All 2 Replies

Use Try Catch method

Try

    'Your Backspace code

Catch ex as Exception

    MsgBox("No Value")
    'I use MsgBox to notify that there's no value.
    'Feel free to use other methods you see fit

End Try

Thank you for the quick response jared.geli.
I've already figured it out!
This is what I've done!
I just want to share it with others who has the same problem.

Here the code:

1. Private Sub Button38_Click(ByVal sender As System.Object, ByVal e As    System.EventArgs) Handles Button38.Click
2. If desiredTextbox.Text.Length <> 0 Then
3. desiredTextbox.Text = desiredTextbox.Text.Substring(0, desiredTextbox.Text.Length - 1)
4. End If
5. End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.