473,511 Members | 14,975 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

format

Tom
I have this

131.988

I want
132

how can I accomplish this?
Feb 6 '08 #1
3 924
"Tom" <To*@yahoo.comwrote in message
news:Ok**************@TK2MSFTNGP06.phx.gbl...
>I have this

131.988

I want
132

how can I accomplish this?

double MyDouble = 131.988;
string MyFormattedDouble = MyDouble.ToString("0");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Feb 6 '08 #2
Your question should be more to the point. Usually a piece of code helps us
give you better answers.

But here it goes

dim value decimal = 131.987
label1.text = format(value, "#0")

will give you 132
--
aaa
"Tom" wrote:
I have this

131.988

I want
132

how can I accomplish this?
Feb 6 '08 #3
If you are looking to just round, you can convert the number to an integer as
well.

VB.NET
Dim decimalNumber As Decimal = 131.988
Dim intNumber As Integer = decimalNumber ' intNumber will be 132
or you can show you are converting it (use one of these methods depending on
how big your integer can get)
Dim intNumber As Integer = Convert.ToInt16(doubleNumber)
Dim intNumber As Integer = Convert.ToInt32(doubleNumber)
Dim intNumber As Integer = Convert.ToInt64(doubleNumber)

or if your starting number is a double:

Dim doubleNumber As Double = 131.988
Dim intNumber As Integer = doubleNumber
C#
double doubleNumber = 131.988;
int integerNumber = Convert.ToInt16(doubleNumber);

or depending on how big your integer will get you can also use:
int integerNumber = Convert.ToInt32(doubleNumber);
int integerNumber = Convert.ToInt64(doubleNumber);

Is your starting number of 131.988 a string?
You can also use (VB.NET):
Dim doubleString As String = "131.988"
Dim intNumberFromString As Integer = doubleString

"Tom" wrote:
I have this

131.988

I want
132

how can I accomplish this?
Feb 6 '08 #4

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

Similar topics

3
2151
by: Lowell Kirsh | last post by:
In Peter Norvig's Infrequently Answered Questions he explains that the following 2 fnctions look almost identical but are not the same: def printf(format, *args): print format % args, def...
15
42977
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
3
19218
by: stevek | last post by:
How do I format an integer. Add commas. 1234565 1,234,565 TIA
6
31128
by: Dario Di Bella | last post by:
Hi all, we have the following urgent issue affecting our development team. Initially we had one particular workstation that failed executing queries on a DB2 database, raising an invalid date...
3
12097
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
11
5919
by: Grumble | last post by:
Hello, I have the following structure: struct foo { char *format; /* format string to be used with printf() */ int nparm; /* number of %d specifiers in the format string */ /* 0 <= nparm <=...
7
6483
by: Alpha | last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm looking for codes that's droping the 2nd digit of a nuber printed out and I suspect it's the code below. Can someone tell me...
4
1623
by: David Morris | last post by:
Hi Could somebody please explain what the following line of code means String.Format("{0}\{1}.{2:00}", C:\, myfile.txt, 1 It's actually the first argument that I don't understand. What is...
13
3283
by: Roy | last post by:
Hi all, I'm creating a project that should always use this date format when displays the dates or create dates. The back end database is a SQL Server and I like to know what is the logical way...
3
1933
by: Carl Trachte | last post by:
Hello. Python 3.0.a1 has been released. I'm trying to get the hang of the new string formatting in the form: '5.66' There are more options in PEP 3101 (fill, alignment, etc.), but I'm having...
0
7252
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
7432
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...
1
7093
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...
0
5676
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,...
0
4743
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...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
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...

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.