This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » ASP » Calculate with asp variables
Reply

Calculate with asp variables

sofie sof
Member



Since: 26 Feb 2004
Posts: 16
Posted 12 Jul 2010 18:27:31

Hi,

In my ms sql database i have 2 numeric fields.
I declared 2 variables and a calculation :

Brutto = (Producten.Fields.Item("BruttoPrijs".Value)
Netto = (Producten.Fields.Item("NettoPrijs".Value)
Winst = Brutto - Netto

I get a code error.
This is my code in asp vbscript:

<%
Brutto = (Producten.Fields.Item("BruttoPrijs".Value)
Netto = (Producten.Fields.Item("NettoPrijs".Value)
Winst = Brutto - Netto
%>

Help is very welcome.

Tx,
Peter

Hi,

In my ms sql database i have 2 numeric fields.
I declared 2 variables and a calculation :

Brutto = (Producten.Fields.Item("BruttoPrijs".Value)
Netto = (Producten.Fields.Item("NettoPrijs".Value)
Winst = Brutto - Netto

I get a code error.
This is my code in asp vbscript:

<%
Brutto = (Producten.Fields.Item("BruttoPrijs".Value)
Netto = (Producten.Fields.Item("NettoPrijs".Value)
Winst = Brutto - Netto
%>

Help is very welcome.

Tx,
Peter
Patrick Woldberg
Official Representative



Since: 11 Feb 2003
Posts: 1,894
Replied 13 Jul 2010 11:50:12
I don't know the error you get, but try converting the values to Double first.

Brutto = CDbl(Producten.Fields.Item("BruttoPrijs").Value)
Netto = CDbl(Producten.Fields.Item("NettoPrijs").Value)
Winst = Brutto - Netto

Reply to this topic

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency