+ Reply to Thread
Results 1 to 5 of 5

How to abstract a number from a string?

  1. #1
    Danny Hoon
    Guest

    How to abstract a number from a string?

    Hi all,

    I'm trying abstract second number from a cell.
    If cell a1=1234, how do I abstract 2 using a function?
    I will need to use 2 for some math calculation.

    I tried this but it don't work.

    Function test(num As String)
    test = num.char(1)
    End Function

    Thank for assisting.
    --
    Danny



  2. #2
    Dave Peterson
    Guest

    Re: How to abstract a number from a string?

    Function test(num As String) as long
    test = mid(num,2,1)
    End Function

    (with no validity checks at all!)

    Danny Hoon wrote:
    >
    > Hi all,
    >
    > I'm trying abstract second number from a cell.
    > If cell a1=1234, how do I abstract 2 using a function?
    > I will need to use 2 for some math calculation.
    >
    > I tried this but it don't work.
    >
    > Function test(num As String)
    > test = num.char(1)
    > End Function
    >
    > Thank for assisting.
    > --
    > Danny


    --

    Dave Peterson

  3. #3
    Danny Hoon
    Guest

    Re: How to abstract a number from a string?

    Thanks Dave!!!
    Care to explain this line?
    Function test(num As String) as long <== you are casting the String to a
    Long data type?

    --
    Danny

    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > Function test(num As String) as long
    > test = mid(num,2,1)
    > End Function
    >
    > (with no validity checks at all!)
    >
    > Danny Hoon wrote:
    >>
    >> Hi all,
    >>
    >> I'm trying abstract second number from a cell.
    >> If cell a1=1234, how do I abstract 2 using a function?
    >> I will need to use 2 for some math calculation.
    >>
    >> I tried this but it don't work.
    >>
    >> Function test(num As String)
    >> test = num.char(1)
    >> End Function
    >>
    >> Thank for assisting.
    >> --
    >> Danny

    >
    > --
    >
    > Dave Peterson




  4. #4
    CLR
    Guest

    Re: How to abstract a number from a string?

    Maybe.........

    =MID(A1,2,1)*1

    Vaya con Dios,
    Chuck, CABGx3


    "Danny Hoon" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all,
    >
    > I'm trying abstract second number from a cell.
    > If cell a1=1234, how do I abstract 2 using a function?
    > I will need to use 2 for some math calculation.
    >
    > I tried this but it don't work.
    >
    > Function test(num As String)
    > test = num.char(1)
    > End Function
    >
    > Thank for assisting.
    > --
    > Danny
    >
    >




  5. #5
    Dave Peterson
    Guest

    Re: How to abstract a number from a string?

    Yep.

    You said that it would be used for further math calculations.

    Danny Hoon wrote:
    >
    > Thanks Dave!!!
    > Care to explain this line?
    > Function test(num As String) as long <== you are casting the String to a
    > Long data type?
    >
    > --
    > Danny
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    > > Function test(num As String) as long
    > > test = mid(num,2,1)
    > > End Function
    > >
    > > (with no validity checks at all!)
    > >
    > > Danny Hoon wrote:
    > >>
    > >> Hi all,
    > >>
    > >> I'm trying abstract second number from a cell.
    > >> If cell a1=1234, how do I abstract 2 using a function?
    > >> I will need to use 2 for some math calculation.
    > >>
    > >> I tried this but it don't work.
    > >>
    > >> Function test(num As String)
    > >> test = num.char(1)
    > >> End Function
    > >>
    > >> Thank for assisting.
    > >> --
    > >> Danny

    > >
    > > --
    > >
    > > Dave Peterson


    --

    Dave Peterson

+ 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