Solved

How to check if number is positive or negative

Posted on 2006-11-18
6
6,521 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordpress display sub menu only when click 12 88
Syntax for query to update table 2 53
SP converting date time to date and time separately 2 33
Diff of the day 2 36
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

740 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