type mismatch when caculating

Discussion in 'ASP General' started by eddie wang, Apr 16, 2004.

  1. eddie wang

    eddie wang Guest

    The following caculcation will result type mismatch:
    boe_net=oil_net+oil_gross .

    Here is the value:
    oil_net: 69997
    oil_grss: 84651


    Here is the code:
    strSQl = "SELECT nvl(ROUND(SUM(A.NET_STD_PB_VOL)),0) OIL_NET,
    ROUND(SUM(A.GROSS_STD_PB_VOL)) OIL_GROSS,
    NVL(ROUND((SUM(A.NET_STD_PB_VOL) / SUM(A.GROSS_STD_PB_VOL)) * 100, 2),0)
    EST_AGGR_OIL_INTEREST "&_
    "FROM OGDWMART.PO_CMPL_MTH_ALLOC_VOL_F A"

    Set rs = conn(strSQl)
    if not rs.EOF then
    oil_int = rs("EST_AGGR_OIL_INTEREST")
    oil_net = rs("OIL_NET")
    oil_gross = rs("OIL_GROSS")
    boe_net=oil_net+oil_gross
    end if

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    eddie wang, Apr 16, 2004
    #1
    1. Advertising

  2. eddie wang

    Scott McNair Guest

    eddie wang <> wrote in news:#hjbL$8IEHA.3968
    @TK2MSFTNGP12.phx.gbl:

    > Set rs = conn(strSQl)
    > if not rs.EOF then
    > oil_int = rs("EST_AGGR_OIL_INTEREST")
    > oil_net = rs("OIL_NET")
    > oil_gross = rs("OIL_GROSS")
    > boe_net=oil_net+oil_gross
    > end if


    Just to be safe, make it:

    boe_net=CInt(oil_net)+CInt(oil_gross)
     
    Scott McNair, Apr 16, 2004
    #2
    1. Advertising

  3. eddie wang

    Al Guest

    How about this

    ReturnValue = clng(A_Value) + clng(B_Value)

    if A_Value Or B_Value exceed the 64bit of a long Type
    then use the cdbl(A_Value) + cdbl(B_Value)

    Good luck..!


    "eddie wang" <> wrote in message
    news:%23hjbL$...
    > The following caculcation will result type mismatch:
    > boe_net=oil_net+oil_gross .
    >
    > Here is the value:
    > oil_net: 69997
    > oil_grss: 84651
    >
    >
    > Here is the code:
    > strSQl = "SELECT nvl(ROUND(SUM(A.NET_STD_PB_VOL)),0) OIL_NET,
    > ROUND(SUM(A.GROSS_STD_PB_VOL)) OIL_GROSS,
    > NVL(ROUND((SUM(A.NET_STD_PB_VOL) / SUM(A.GROSS_STD_PB_VOL)) * 100, 2),0)
    > EST_AGGR_OIL_INTEREST "&_
    > "FROM OGDWMART.PO_CMPL_MTH_ALLOC_VOL_F A"
    >
    > Set rs = conn(strSQl)
    > if not rs.EOF then
    > oil_int = rs("EST_AGGR_OIL_INTEREST")
    > oil_net = rs("OIL_NET")
    > oil_gross = rs("OIL_GROSS")
    > boe_net=oil_net+oil_gross
    > end if
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Al, Apr 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. data type mismatch error

    , Aug 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    637
    Karl Seguin
    Aug 10, 2005
  2. type mismatch error

    , Aug 12, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,365
    Kevin Spencer
    Aug 12, 2005
  3. Artie Gold

    Re: type mismatch

    Artie Gold, Feb 28, 2004, in forum: C Programming
    Replies:
    0
    Views:
    397
    Artie Gold
    Feb 28, 2004
  4. eddie wang

    type mismatch when caculating

    eddie wang, Apr 16, 2004, in forum: ASP General
    Replies:
    1
    Views:
    105
  5. programmingzeal
    Replies:
    0
    Views:
    1,124
    programmingzeal
    May 6, 2012
Loading...

Share This Page