473,698 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET Absolute value

How do I get the absolute value of an expression in VB.NET? The new ABS
function looks scary to me!

Thanks
Bill
Nov 20 '05 #1
4 63493
System.Math.Abs (<numeric expression here>)

What's scary about it? :-)

-Rob Teixeira [MVP]

"Bill Nguyen" <bi************ *****@jaco.com> wrote in message
news:O%******** ********@TK2MSF TNGP12.phx.gbl. ..
How do I get the absolute value of an expression in VB.NET? The new ABS
function looks scary to me!

Thanks
Bill

Nov 20 '05 #2
Bill,
How do I get the absolute value of an expression in VB.NET? Have you tried System.Math.Abs ?
The new ABS
function looks scary to me! Or are you referring to a different ABS function?
Dim x As Integer
x = Math.Abs(-1)

Alternatively you can import System.Math:

Imports System.Math

Dim x As Integer
x = Abs(-1)

Hope this helps
Jay

"Bill Nguyen" <bi************ *****@jaco.com> wrote in message
news:O%******** ********@TK2MSF TNGP12.phx.gbl. .. How do I get the absolute value of an expression in VB.NET? The new ABS
function looks scary to me!

Thanks
Bill

Nov 20 '05 #3
"Bill Nguyen" <bi************ *****@jaco.com> schrieb
How do I get the absolute value of an expression in VB.NET? The new
ABS function looks scary to me!


Why scary?

value2 = math.abs(value1 )
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
* "Bill Nguyen" <bi************ *****@jaco.com> scripsit:
How do I get the absolute value of an expression in VB.NET? The new ABS
function looks scary to me!


?!?

\\\
d = Math.Abs(...)
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3540
by: Claudio Lapidus | last post by:
Hello Evidently is possible to have a negative time interval: clapidus=> select interval '-1'; interval ----------- -01:00:00 However, there seems to be no provision to get the absolute value in such
34
16860
by: Christopher Benson-Manica | last post by:
I'm trying to compute the absolute value of an integer using only bitwise operators... int x; sscanf( "%d", &x ); printf( "%d\n", (x^((~((x>>31)&1))+1)) + ((x>>31)&1) ); That works, but it assumes 32 bit integers. Is there a portable/standard way to do this? Or are ANSI integers always 32 bits? If not, is using sizeof(int) * 8 - 1 as the shift value an acceptable alternative?
0
1137
by: mike82y | last post by:
I want to set da,db,dc to absolute value.. how do i do that?? many thanks abs(da) = a - aaa; abs(db) = b - bbb; abs(dc) = c - ccc; Mike
49
6097
dima69
by: dima69 | last post by:
Hi all. Here is a problem. I want to sort a form by absolute value. Let's say, if I have a field named "theSum", I'd like to set the form OrderBy property to "Abs()". If I use "Advanced filtering\sorting" from "Records" menu, it works just fine, and OrderBy proprty becomes "Abs()". But when I do the same thing manually or programmatically, it doesn't work. So I cannot figure out what is the trick here and how to make this work.
7
2883
by: Chad | last post by:
I really don't understand how something like.. #define abs(x) (((x) < 0) ? -(x) : (x)) could cause a possible overflow.
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.