Math: Decimal number between 2 numbers

  • Thread starter Thread starter pvong
  • Start date Start date
P

pvong

I'm using VS2005 trying to do a simple ASP.net page.

I'm just trying to specify an IF state where it is looking at the answer to
see if it's between 0.02 and -0.02. Where I'm stuck is the negative number.
Below is the simple line and what I tried but I didn't work. I've already
defined CheckCurrentMktPx and CheckExecPx.


Dim CheckAnswer As Decimal = (CheckCurrentMktPx - CheckExecPx) /
CheckCurrentMktPx

if checkanswer > 0.02 or < -0.02
 
pvong said:
I'm just trying to specify an IF state where it is looking at the answer
to see if it's between 0.02 and -0.02. Where I'm stuck is the negative
number. Below is the simple line and what I tried but I didn't work. I've
already defined CheckCurrentMktPx and CheckExecPx.

Dim CheckAnswer As Decimal = (CheckCurrentMktPx - CheckExecPx) /
CheckCurrentMktPx

if checkanswer > 0.02 or < -0.02


In addition to the other reply, you could write 'If checkanswer > 0.02
OrElse checkanswer < -0.02 Then...'.
 
pvong said:
I'm using VS2005 trying to do a simple ASP.net page.

I'm just trying to specify an IF state where it is looking at the answer to
see if it's between 0.02 and -0.02. Where I'm stuck is the negative number.
Below is the simple line and what I tried but I didn't work. I've already
defined CheckCurrentMktPx and CheckExecPx.


Dim CheckAnswer As Decimal = (CheckCurrentMktPx - CheckExecPx) /
CheckCurrentMktPx

if checkanswer > 0.02 or < -0.02

There is no shorthand syntax for comparing a single value against two
other values. You have to compare the values independently.

Also, as you are using the Decimal data type, you should compare it
against Decimal literal values, not Double literal values.

If checkAnswer < -0.02m or checkAnswer > 0.02m Then
 
Back
Top