-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