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
        Next
        TextBox1.Text = rep
    End Sub

Result

Before clicking the button:

vb.net remove numbers

After clicking the button:

vb.net removing numbers from string


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.