473,405 Members | 2,171 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,405 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 5916
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 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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,...

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.