0

-My code sutomatically adds a hyphen at certain positions in the string, but I am unable to delete the second hyphen if I want to edit what I've typed in before that. Is there a way to fix this?

Private Sub txtISBN_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtISBN.KeyPress
        If txtISBN.TextLength = 1 Then
        txtISBN.Text = txtISBN.Text + "-"
        txtISBN.SelectionStart = Len(txtISBN.Text)
    Else
        If txtISBN.TextLength = 9 Then
        txtISBN.Text = txtISBN.Text + "-"
        txtISBN.SelectionStart = Len(txtISBN.Text)
    Else
        If txtISBN.TextLength = 11 Then
        txtISBN.Text = txtISBN.Text + "-"
        txtISBN.SelectionStart = Len(txtISBN.Text)
    End If
    End If
    End If
End Sub
End Class
3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by Icone
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.