extracting numbers out of a string

i have a field that has employeeid aand employee name example

" iyajimi1234" or
"iyajimi-12234"

"iyajimi/0234"

, i need to be able to get the numbers out of these string values into another feild.

any ideas




Answer this question

extracting numbers out of a string

  • wreckless89

    These forums are for VB.NET.    Are you using VB.NET

    At the top of the forum is a sticky post called

    How to receive the best support for your question http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=227781&SiteID=1

    Please read this when posting to ensure that you get a response to your question.   Providing as much information as possible for us.

     

     


  • Mark Rideout

    Heres I think what you need - Function NumbersOnly

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim s As String = "iyajimi1234"
    MsgBox(NumbersOnly(s))

    s = "iyajimi-1234"
    MsgBox(NumbersOnly(s))
    End Sub

    Function NumbersOnly(ByVal s As String) As String
    Dim OutputString As String = ""
    For Each c As Char In s
    If Char.IsNumber(c) = True Or c = "-" Then
    OutputString = OutputString & c
    End If
    Next
    Return OutputString
    End Function
    End Class


  • Tantanoid

    than ks, but i am actually trying to do this using dts(active x)

    i will look to see if this function exits in the language browser for active x thanks



  • extracting numbers out of a string