Question: How do I add the ability to backspace in the txtWord txt block in the code below? Public Class Form1 Private Sub Remove_UnwantedText(sender As Object,
How do I add the ability to backspace in the txtWord txt block in the code below?
Public Class Form1 Private Sub Remove_UnwantedText(sender As Object, e As KeyPressEventArgs) Handles txtWord.KeyPress If Char.IsLetter(e.KeyChar) Or e.KeyChar = "." Then 'Only letter e.Handled = False ElseIf Char.IsWhiteSpace(e.KeyChar) Then 'only whitespace allowed e.Handled = False Else e.Handled = True End If End Sub Private Sub BtnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click Dim trimText As String = System.Text.RegularExpressions.Regex.Replace(txtWord.Text, "\s{2,}", " ") txtWord.Text = trimText MessageBox.Show("Dear Sir or Ma'am, Your TRIMMED Text is" & trimText, "Unit VII Project Output") End Sub 'Click Close to Close Application Private Sub BtnClose_Click(sender As Object, e As EventArgs) Handles BtnClose.Click Me.Close() End Sub 'Click Clear to Clear txtWord Field Private Sub BtnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click txtWord.Text = "" End Sub End Class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
