IT KNOWLEDGE

IT KNOWLEDGE
BC

Saturday, May 24, 2014

Remove Only Number or Letter from Textbox (VB.Net)

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




Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: itech-9999

0 comments: