Solved

How to check if number is positive or negative

Posted on 2006-11-18
6
6,495 Views
Last Modified: 2012-05-05
In classic asp, how do I check if a number is positive or negative.
Say 20 - 10 = -10. How do i check if its - 10?
I'm tryin to do a sales report graph where todays data is compared with yesterdays and the percent of increase or decrese is displayed.
So if its -10 Response.write "Decrease in Sales"
0
Comment
Question by:dpinto04
6 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 17973893
you can format a number....

<%=formatnumber(strNumber,2,0,-1)%>

this will put a parentheses around a negative number....so I guess, you could always do a string check against it...

if instr(formatnumber(strNumber,2,0,-1),"(") > 0 then
  response.write("Decrease In Sales"
end if
0
 
LVL 16

Accepted Solution

by:
CWS (haripriya) earned 20 total points
ID: 17977497
Dim numA, numB, numDiff

numDiff = numA - numB

' All negative numbers are less than zero.
if numDiff < 0 then
      Response.write "Decrease in Sales"
end if

0
 
LVL 9

Expert Comment

by:deathtospam
ID: 17979465
The VBScript Sgn function ( http://tinyurl.com/yz9rpo ) sounds like what you need:

====================================
Arguments
The number argument can be any valid numeric expression.

Return Value
The Sgn function has the following return values:

If number is  Sgn returns  
Greater than zero
 1
Equal to zero
 0
Less than zero
 -1
====================================


-= DeathToSpam =-
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP equivalent to Windows findstr 3 71
C# onclick function to call another form with parameter 10 54
ASP Sessions Being Cleared/Modified 6 65
XML Parsing Classic ASP 5 50
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now