+ Reply to Thread
Results 1 to 4 of 4

Reformat Number

  1. #1

    Reformat Number

    I am extracting data from a program that collects project data in a
    number of areas.
    The project number is extracted just as it comes out of the program,
    sometime with parentheses , commas, or dashes in between its parts.
    The field the number is input into is a text field.

    What I would like to do is to remove all symbols from the number and
    make the number one long string of digits. Is there any way to do
    this?

    Thanks in advance for the help.


  2. #2
    Tom Ogilvy
    Guest

    Re: Reformat Number

    ? StripNonChar("!@#$%^1234590ABCD abxyz&*(){}")
    1234590ABCDabxyz


    Public Function StripNonChar(s)
    Dim s1 As String
    Dim i As Long, schr As String

    For i = 1 To Len(s)
    schr = UCase(Mid(s, i, 1))
    If IsNumeric(schr) Or (schr >= "A" And schr <= "Z") Then
    s1 = s1 & Mid(s, i, 1)
    End If
    Next
    StripNonChar = s1
    End Function

    --
    Regards,
    Tom Ogilvy



    <[email protected]> wrote in message
    news:[email protected]...
    > I am extracting data from a program that collects project data in a
    > number of areas.
    > The project number is extracted just as it comes out of the program,
    > sometime with parentheses , commas, or dashes in between its parts.
    > The field the number is input into is a text field.
    >
    > What I would like to do is to remove all symbols from the number and
    > make the number one long string of digits. Is there any way to do
    > this?
    >
    > Thanks in advance for the help.
    >




  3. #3
    Toppers
    Guest

    RE: Reformat Number

    Hi,
    Try:

    Sub RemoveNonNumeric()

    Dim projnum as string, newprojnum as string

    projnum = "123(45-*Ab345]"
    newprojnum = ""

    For i = 1 To Len(projnum)
    If IsNumeric(Mid(projnum, i, 1)) Then newprojnum = newprojnum + Mid(projnum,
    i, 1)
    Next i
    MsgBox newprojnum
    End Sub

    "[email protected]" wrote:

    > I am extracting data from a program that collects project data in a
    > number of areas.
    > The project number is extracted just as it comes out of the program,
    > sometime with parentheses , commas, or dashes in between its parts.
    > The field the number is input into is a text field.
    >
    > What I would like to do is to remove all symbols from the number and
    > make the number one long string of digits. Is there any way to do
    > this?
    >
    > Thanks in advance for the help.
    >
    >


  4. #4
    Ron Rosenfeld
    Guest

    Re: Reformat Number

    On 16 Feb 2006 10:41:44 -0800, [email protected] wrote:

    >I am extracting data from a program that collects project data in a
    >number of areas.
    >The project number is extracted just as it comes out of the program,
    >sometime with parentheses , commas, or dashes in between its parts.
    >The field the number is input into is a text field.
    >
    >What I would like to do is to remove all symbols from the number and
    >make the number one long string of digits. Is there any way to do
    >this?
    >
    >Thanks in advance for the help.


    Here's one way:

    ======================
    Option Explicit
    Sub GetDigits()
    Const str As String = "1234ab()?4567Aa></910"
    Dim res As String
    Dim i As Long
    Dim s As String

    For i = 1 To Len(str)
    s = Mid(str, i, 1)
    res = res & IIf(s Like "[0-9]", s, "")
    Next i

    Debug.Print res

    End Sub
    ====================

    --ron

+ 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