473,378 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Math: Decimal number between 2 numbers

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
Jun 10 '07 #1
4 1333
if checkanswer 0.02 or < -0.02
>

This is not Legal VB

You might try...
-------------------------------------------------------------
if checkanswer 0.02 or checkanswer < -0.02 then
' ... some code here
endif
-------------------------------------------------------------

you might also want to look into the abs function

-------------------------------------------------------------
if abs(checkanswer) 0.02 then
' ... some code here
end if
-------------------------------------------------------------

--
Rory
Jun 10 '07 #2
Perfect.

Thanks!

"Rory Becker" <Ro********@newsgroup.nospamwrote in message
news:b0*************************@msnews.microsoft. com...
>if checkanswer 0.02 or < -0.02


This is not Legal VB

You might try...
-------------------------------------------------------------
if checkanswer 0.02 or checkanswer < -0.02 then
' ... some code here
endif
-------------------------------------------------------------

you might also want to look into the abs function

-------------------------------------------------------------
if abs(checkanswer) 0.02 then
' ... some code here
end if
-------------------------------------------------------------

--
Rory


Jun 10 '07 #3
"pvong" <phillip*at*yahoo*dot*comschrieb:
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...'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 10 '07 #4
pvong wrote:
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

--
Göran Andersson
_____
http://www.guffa.com
Jun 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Craig Bailey | last post by:
Someone please explain what alternate universe I fell into this afternoon when PHP started telling me that 2 doesn't equal 2. Not sure about you, but when I run this, it tells me 59001.31 doesn't...
89
by: Radioactive Man | last post by:
In python 2.3 (IDLE 1.0.3) running under windows 95, I get the following types of errors whenever I do simple arithmetic: 1st example: >>> 12.10 + 8.30 20.399999999999999 >>> 1.1 - 0.2...
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
1
by: cody | last post by:
the documentation states that Math.Round supports banker's rounding but it also states that if the last number is 5 it will rounded up if the whole number is even, otherwise rounded down which is...
3
by: Dave | last post by:
I'm making a physics that uses very small numbers such as 9.88E-19. that is, 9.88 times 10 to the power of -19. I've run into a few problems doing calculations with numbers like these. the first...
11
by: Whidbey Wave | last post by:
Hello Gurus, Here is a problem, where i am unable to reason HOW it happens? I wrote a dll using math.log. This dll when used within application A works fine, but not with application B. On...
4
by: Chris Davoli | last post by:
The folllowing will round to 526, but it should round to 527. It works correctly for all other numbers, except for this one. Does anybody know of a bug in Math.Round? Dim ldecWater As Decimal =...
10
by: David Coleman | last post by:
I am running VS 2003 and have applied SP1. (On WinXP SP2, .Net 1.1) In the Command Window I get the following ? Math.Round(0.715, 2) 0.72 ? Math.Round(0.725, 2) 0.72 ? Math.Round(0.735, 2)...
1
by: TC | last post by:
I am getting small math errors when I use a query to convert a column's data type from Text to Single. I am using a calculated column with the following expression. HighSchoolGPA:...
4
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.