Solved

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

Posted on 2006-07-20
2
288 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 125 total points
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

17 Experts available now in Live!

Get 1:1 Help Now