+ Reply to Thread
Results 1 to 4 of 4

How to crop only numbers from a string?

  1. #1
    serdar
    Guest

    How to crop only numbers from a string?

    function should return number 41 from string:
    "vivaldi - 4 - seasons - movement/1"



  2. #2
    Rowan Drummond
    Guest

    Re: How to crop only numbers from a string?

    Maybe:

    Sub GetIt()
    Dim str As String
    str = "vivaldi - 4 - seasons - movement/1"
    MsgBox num(str)

    End Sub

    Function num(inpt As String)
    Dim i As Integer
    For i = 1 To Len(inpt)
    If IsNumeric(Mid(inpt, i, 1)) Then
    num = num & Mid(inpt, i, 1)
    End If
    Next i
    num = CLng(num)
    End Function

    Regards
    Rowan

    serdar wrote:
    > function should return number 41 from string:
    > "vivaldi - 4 - seasons - movement/1"
    >
    >


  3. #3
    serdar
    Guest

    Re: How to crop only numbers from a string?

    thanks for ur effort to code the entire function. seems u r real fast and
    pro. just IsNumeric( ) would be enough also but u spend ur time to write
    all.

    well, i am assuming IsNumeric( ) crops only 1234567890



    "Rowan Drummond" <rowanzsaNotThis@hotmail.com>, haber iletisinde sunlari
    yazdi:u2EqiRM5FHA.3908@tk2msftngp13.phx.gbl...
    > Maybe:
    >
    > Sub GetIt()
    > Dim str As String
    > str = "vivaldi - 4 - seasons - movement/1"
    > MsgBox num(str)
    >
    > End Sub
    >
    > Function num(inpt As String)
    > Dim i As Integer
    > For i = 1 To Len(inpt)
    > If IsNumeric(Mid(inpt, i, 1)) Then
    > num = num & Mid(inpt, i, 1)
    > End If
    > Next i
    > num = CLng(num)
    > End Function
    >
    > Regards
    > Rowan
    >
    > serdar wrote:
    >> function should return number 41 from string:
    >> "vivaldi - 4 - seasons - movement/1"




  4. #4
    Rowan Drummond
    Guest

    Re: How to crop only numbers from a string?

    IsNumeric returns true or false based on the input so:
    ? isnumeric(5) True
    ? isnumeric("b") False
    The function does the cropping based on these results for each character
    in the string.

    Regards
    Rowan

    serdar wrote:
    > thanks for ur effort to code the entire function. seems u r real fast and
    > pro. just IsNumeric( ) would be enough also but u spend ur time to write
    > all.
    >
    > well, i am assuming IsNumeric( ) crops only 1234567890
    >
    >
    >
    > "Rowan Drummond" <rowanzsaNotThis@hotmail.com>, haber iletisinde sunlari
    > yazdi:u2EqiRM5FHA.3908@tk2msftngp13.phx.gbl...
    >
    >>Maybe:
    >>
    >>Sub GetIt()
    >> Dim str As String
    >> str = "vivaldi - 4 - seasons - movement/1"
    >> MsgBox num(str)
    >>
    >>End Sub
    >>
    >>Function num(inpt As String)
    >> Dim i As Integer
    >> For i = 1 To Len(inpt)
    >> If IsNumeric(Mid(inpt, i, 1)) Then
    >> num = num & Mid(inpt, i, 1)
    >> End If
    >> Next i
    >> num = CLng(num)
    >>End Function
    >>
    >>Regards
    >>Rowan
    >>
    >>serdar wrote:
    >>
    >>>function should return number 41 from string:
    >>> "vivaldi - 4 - seasons - movement/1"

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1