Remove All Numbers From a TextBox or a String - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This code is used to remove all the numbers found in a string or a textbox in Visual Basic .NET

You can have a Button that will be used to remove all the numbers found in a textbox

remove all numbers in visual basic

The Code

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim rep As String = String.Empty
        For i As Integer = 0 To TextBox1.Text.Length - 1
            If Not IsNumeric(TextBox1.Text.Substring(i, 1)) Then
                rep += TextBox1.Text.Substring(i, 1)
            End If
        TextBox1.Text = rep
    End Sub


Before clicking the button: remove numbers

After clicking the button: removing numbers from string

Share This

Home | About | Contact | Privacy Policy

Copyright 2017 - All Rights Reserved.