473,226 Members | 1,487 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Division in 2 decimals

How can I display the result of a division operation in 2 dicimal digits only?

e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

Thanks

Nov 20 '05 #1
4 5904
You can use System.Math.Round

or you can use

String.Format
"Amjad" <an*******@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
How can I display the result of a division operation in 2 dicimal digits only?
e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

Thanks

Nov 20 '05 #2
"Amjad" <an*******@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
How can I display the result of a division operation in 2 dicimal digits only?
e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

Thanks


Use Math.Round

Dim MyValue As Double = Math.Round(10 / 3, 2)

Erik
Nov 20 '05 #3
or...

dim value as Double.
value.ToString("N2") --> 123,456.78
dominique
"Amjad" <an*******@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
How can I display the result of a division operation in 2 dicimal digits only?
e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

Thanks

Nov 20 '05 #4
* "=?Utf-8?B?QW1qYWQ=?=" <an*******@discussions.microsoft.com> scripsit:
How can I display the result of a division operation in 2 dicimal digits only?

e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33


\\\
Dim d As Double = 1234.5678
MsgBox(d.ToString("N2"))
MsgBox(String.Format("{0:N2}", d))
MsgBox(Math.Round(d, 2).ToString())
....
///

--
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

3
by: Oswald | last post by:
Hey, how can I set the number of decimals? Example: 5 decimals 2.12345 2 decimals 2.12 I've found something about NumberFormat in the API, but without an example I can't solve this...
4
by: Bill | last post by:
I have some values that I want to display as percent, such as the retail price/wholesale price. In some instances, the wholesale price is zero, so I get a division by zero error. What can I do...
15
by: joel | last post by:
I have a table which I want to update by dividing one field into another. The update runs with no errors, but the results come out as only a positive integer number. The datatype for the result...
2
by: westjon64 | last post by:
i am fairly new to c++, i need to know how to make it so you can input decimals into a file using the cin >> a command instead of just being able to input whole numbers and also how to make it so...
6
by: Donal McWeeney | last post by:
Hi, Is there a way to specify on the predefined format strings like P and N that you want displayed all the decimals in the number... for example 3 will display 3 2.1 will display 2.1...
17
by: seb.haase | last post by:
Hi, Is it true that that "Python 3000" is dead ? Honestly I think that e.g. changing 5/2 to be 2.5 (instead of 2) would just break to much code :-( On the otherhand I'm using Python as "Matlab...
13
by: jamesonang | last post by:
Supposed unsigned int(32 bits) is the largest number that computer can represent with a single variable. Now, i have a big integer ( less than 64 bit, but great than 32 bit) . i represent it by...
12
by: CNiall | last post by:
I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of...
8
by: =?Utf-8?B?a2FyaW0=?= | last post by:
Hello All, why is this code is not showing the result in this format: 0.00 and showing it as only 0 Private Sub btn1_Click Debug.Print(Format$(Rnd() * 100, "0.00")) Dim d As Double =...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.