This tutorial will show you how to remove only Number or only Letter from textbox. I designed one Textbox for input text and another to Buttons which one is Remove Number and other is Remove Text. All both buttons us Click_Event:
- Remove Number: will remove all number from textbox when we click.
- Remove Text: will remove all letter from textbox when we click.
No | Control type | Name | Text |
1 | Form1 | FormRemoveNumber | Remove Only Number/Text |
2 | TextBox1 | TextBoxWord | |
3 | Button1 | ButonRemoveText | Remove Text |
4 | Button2 | ButtonRemoveNumer | Remove Number |
Code
Public Class FormRemoveNumber
Private Sub ButtonRemoveText_Click(sender As Object, e As EventArgs) Handles
ButtonRemoveText.Click
Dim rep As String = String.Empty
For i As Integer = 0 To TextBoxWord.Text.Length - 1
If IsNumeric(TextBoxWord.Text.Substring(i, 1)) Then
rep +=
TextBoxWord.Text.Substring(i, 1)
End If
Next
TextBoxWord.Text = rep
End Sub
Private Sub ButtonRemoveNumber_Click(sender As Object, e As EventArgs) Handles
ButtonRemoveNumber.Click
Dim rep As String = String.Empty
For i As Integer = 0 To TextBoxWord.Text.Length - 1
If Not IsNumeric(TextBoxWord.Text.Substring(i, 1)) Then
rep +=
TextBoxWord.Text.Substring(i, 1)
End If
Next
TextBoxWord.Text = rep
End Sub
End Class
0 comments:
Post a Comment