?
Solved

VB.Net is there a function to return the difference between two values?

Posted on 2006-07-20
2
Medium Priority
?
304 Views
Last Modified: 2010-04-23
I need to compare a zero or greater value to a value that may be negative and return the difference between the two values as a positive number  these variables are all stored as data type Double.
 
For example:  

Value 1 = 17
Value 2 = -4

Would like function to return 21.

Thanks,
Jon
0
Comment
Question by:JMO9966
2 Comments
 
LVL 14

Accepted Solution

by:
ptakja earned 375 total points
ID: 17151469
Sure ;-)

Diff = Math.Abs(Value1-Value2)

All joking aside, the short answer is no.  However, you could easily write your own.

Public Function Diff(ByVal Value1 As Double, ByVal Value2 As Double) As Double
    Return Math.Abs(Value1 - Value2)
End Function
0
 

Author Comment

by:JMO9966
ID: 17151722
I ended up turning the negative number value2 into a positive and adding to value1.

If FutureBalance < OrderPoint And FutureBalance < 0 Then
            FutureSuggOrder = Math.Abs(FutureBalance) + OrderPoint
        ElseIf FutureBalance < OrderPoint And FutureBalance >= 0 Then
            FutureSuggOrder = OrderPoint - FutureBalance
        Else
            FutureSuggOrder = 0
        End If
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

850 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