473,387 Members | 1,597 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,387 software developers and data experts.

decimal format

27
i want to write a decimal value to a xml attribute.

my code is


element.setattribute(amount,myamount.decimalvalue. tostring);
my amount value is 10.
this displayes as 10.

instead when my amount is 10 i want to display as 10.0
when my amount is 10.5 want to display as 10.5

how can i format like this ?
Sep 4 '07 #1
3 1280
Plater
7,872 Expert 4TB
.ToString() has a .ToString(string) varient.
Look up what you cand put inside, I think it's like .ToString("N") but I might be wrong.
Sep 4 '07 #2
phvfl
173 Expert 100+
Hi mpl,

As Plater said use the overload of the ToString method. The format string for the format that you have specified would be "0.0" so the code would be:

Expand|Select|Wrap|Line Numbers
  1. decimalValue.ToString("0.0")
  2.  
The Microsoft reference for number format strings can be found here
Sep 4 '07 #3
mpl
27
Thanks a lot .It works

Hi mpl,

As Plater said use the overload of the ToString method. The format string for the format that you have specified would be "0.0" so the code would be:

Expand|Select|Wrap|Line Numbers
  1. decimalValue.ToString("0.0")
  2.  
The Microsoft reference for number format strings can be found here
Oct 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: serpent17 | last post by:
Hello, I was looking at this: http://docs.python.org/lib/module-struct.html and tried the following >>> import struct >>> struct.calcsize('h') 2 >>> struct.calcsize('b')
4
by: John Bowman | last post by:
Hi, A couple Q's , so I've come to the experts<g>. 1) I need a definitive answer to the following debate. I've got a couple developers who disagree on the following question. We've got an XML...
3
by: Mark | last post by:
I have a Decimal or a Double - your choice. I'd like to print the number as string with a specified number of decimal places. Let's say my number 110.5, and I'd like to capture it in a string...
10
by: Paul Sullivan | last post by:
decimal d; d = 1.1M OR d= (decimal) 1.1 Discussioon
1
by: Mythran | last post by:
Dim value As Decimal = 1234.56 Dim format As String = _ "Positive $#,##0.00;Negative $#,##0.00;" Dim s As String = value.ToString(format) Dim d As Decimal = Decimal.Parse(s) The last line...
11
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a...
2
by: hunslair | last post by:
This is a really basic question. I am taking a teach yourself beginners course on Access 2003 and have run into a road block on one practice. In a select query, I have created a simple calculation...
12
by: ThunderMusic | last post by:
Hi, We have a part of our application that deals with millions of records and do some processing of them. We've achieved a pretty good performance gain by developping a custom DateTime.ToString...
7
by: Andrus | last post by:
How to create format string for decimal data type which shows blank for zero and default format otherwize ? I tried format string "f;f;#" but this shows f for nonzero numbers. Andrus. ...
3
by: =?Utf-8?B?THVpZ2k=?= | last post by:
Hi all, with this code: decimal? test = 1200345.56m; decimal? test2 = Decimal.Parse(String.Format("{0:0,0.000}", test)); i can not obtain a decimal value with thousands separators (but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.