Results 1 to 3 of 3

Thread: computations!!!

  1. #1
    Join Date
    Dec 1969

    Default computations!!!

    here&#039;s my problem....<BR><BR>I need to compute for the total price of a product based on two elements, its quantity, which in this case will be the input of the user, and the other, its unit price, whose value will be taken from the database...<BR><BR>The quantity will be taken from a textbox input so its type would be of text, while the unit price is of data type decimal in the SQL Server database...<BR><BR>What I need? I need to get the total price such that:<BR><BR>quantity x unit price = total price...<BR>e.g. 2 x 250.50 = 501.00<BR><BR>now since the two elements are of different data types, how should I go about this? Another thing, is the datatype decimal the correct datatype for unit price?

  2. #2
    Join Date
    Dec 1969

    Default RE: computations!!!

    congratulations, you&#039;ve won a prize.<BR><BR>look into CDbl() and the * operator. (basic, basic basic)

  3. #3
    Join Date
    Dec 1969

    Default Atrax should have mentioned...

    ...that VBScript can&#039;t handle the DECIMAL data type from the DB, at all. Which is why he has you convert it to floating point with CDBL before using it.<BR><BR>BUT...<BR><BR>But why not store the unit price as a HIDDEN field on the form? In which case both it and the quantity will *really* be strings when they hit the next ASP page via Request.Form or Request.QueryString??<BR><BR>

Posting Permissions

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