Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

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

Posted on 2006-07-20
2
Medium Priority
?
300 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

647 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