I need help urgently!!! please help me!!! or pls read in!!!
Eliminate Pivot Table Annoyances
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 9 of 9

Thread: I need help urgently!!! please help me!!! or pls read in!!!

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    73
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    okay, i am doing this as ASP, but very similar to excel, so i think some1 may know about this simple stuff, but i am stuck on it. pls help

    If Request("Number1") = "303" Then
    Cost1 = "16"
    End If
    If Request("Number2") = "304" Then
    Cost2 = "30"
    End If

    This bit is fine, but I need to add the 2 costs together to write another if function, saying if the 2 costs together cost more than certain amount, then do something... how do u do adding in an if function???

    If Cost1 + Cost2 > "40" Then
    Error = "cost too much"
    Else

    but this does not work, can any help me with this, i got the same problem in excel as well, but pls remmeber this is asp

    pls help me,

    gamestore@hotmail.com


  2. #2
    Board Regular
    Join Date
    Mar 2002
    Posts
    73
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    strange that + does not work, but * bloody work which I don't need...

    i am still stuck, pls give me some help

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    73
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    pls help

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,936
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    If Request("Number1") = "303" Then
    Cost1 = "16"
    End If
    If Request("Number2") = "304" Then
    Cost2 = "30"
    End If


    If Cost1 + Cost2 > "40" Then
    Error = "cost too much"
    Else
    Hi,

    You're using strings (text) for your costs. That won't help. Use something like this:

    If Request("Number1") = "303" Then
    Cost1 = 16
    End If
    If Request("Number2") = "304" Then
    Cost2 = 30
    End If


    As for the second bit - have you missed some code out of your post or is this the code in full? If so the you're missing an End If. If you use an If statement which is not all on one line then you need to end it with an End If e.g.

    If Cost1 + Cost2 > 40 Then
    Error = "cost too much"
    End If

    HTH,
    Dan


    [ This Message was edited by: dk on 2002-04-06 09:18 ]

  5. #5
    MrExcel MVP Anne Troy's Avatar
    Join Date
    Feb 2002
    Location
    Westwood NJ
    Posts
    2,581
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I've called in an ASPer that is familiar with Excel. Might take a bit till he gets here.

    I was on the same track that you're using quotes on numbers when quotes are generally referring to text.
    ~Anne Troy

  6. #6
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Why not use another variable to hold the total? e.g.



    TotalCost = Cost1 + Cost2

    If TotalCost > "40" Then
    Error = "cost too much"
    Else


    It could be that the If statement is having problems with the summation.

    HTH

    _________________
    [b] Mark O'Brien

    [ This Message was edited by: Mark O'Brien on 2002-04-06 10:23 ]

  7. #7
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    799
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default



    If Request("Number1") = "303" Then
    Cost1 = "16"
    End If
    If Request("Number2") = "304" Then
    Cost2 = "30"
    End If

    TotalCost=cint(Cost1)+cint(Cost2)

    Use TotalCost however you need as number now.

    I mean :

    If cint(Cost1) + cint(Cost2) > 40 Then
    Error = "cost too much"
    Else

    regards

    _________________
    Oz ~ TheWordExpert

    [ This Message was edited by: smozgur on 2002-04-06 11:01 ]

  8. #8
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    799
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    A question:

    Why do you set Cost1 and Cost2 as string instead directly numbers?

    Another way of solving it, you remember what we do sometimes in Excel:

    Cost1*1 + Cost2*1

    if they are still strings. Remember (+) isnot arithmetic operator as first if parameters are string. But (*) is always an arithmetic. So if you use (*) it will be executed as first and *1 will convert strings to numbers and then (+) will run as arithmatic operator.

    Regards



  9. #9
    Board Regular
    Join Date
    Mar 2002
    Posts
    73
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    but I have just tried dk method , and he is right, it works.

    i just tested it...

    thanks dk

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com