473,473 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

NumberFormatInfo Help required

Why do I still have to provide a 'String Format' when I have created a
NumberFormatInfo object (nfi) that should display what I need. For
example I have created a default NumberFormatInfo now when I use this
to retrieve a decimal value in the format of '#0.00', i.e. 'string str
= row.amount.Value.ToString(nfi);' but if the value is '0' (zero) then
'str' is formatted to '0' and if the value is '1.1' then 'str' is
formatted to '1.10'. So it works if the value is not '0' but it should
produce '0.00' if the value is '0'. To overcome this I have used the
following: 'string str = row.amount.Value.ToString("C", nfi);' which
forces it to behave like a currency, as I want it to.

Can anybody help me to create a NumberFormatInfo object that will
display '0' as '0.00' without using the 'String Format' setting in the
'ToString' method?

Regards

Billy

Mar 23 '06 #1
1 2448
Sorted it ...

Just use the String Format of 'F'

'string str = row.amount.Value.ToString("F")

If the amount = '0' then the str will now equal '0.00'

Billy

Mar 23 '06 #2

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

Similar topics

5
by: Lorenzo Bolognini | last post by:
Hi all, i need to detect whether a field is required or not. I'm using this code for building a string to convert later to an array (by Split) of which each element matches the field index (ex....
2
by: bufbec1 | last post by:
I am pretty good with Access, but do not understand VBA. I have researched this topic and see only VBA answers, so I hope someone can help with my specific question. I have 2 fields for an...
0
by: Dennis Myrén | last post by:
Hi. I use a System.Globalization.NumberFormatInfo (a System.IFormatProvider derival) instance for formatting numbers. I want to use the NumberDecimalDigits member property to round the numbers...
0
by: Freddy | last post by:
Hi, I am using the following lines of code to format a number according to a culture: //Get the number format according to the user culture. NumberFormatInfo nfi = new CultureInfo(...
1
by: Dave Wurtz | last post by:
All, I have a NumberFormatInfo object with specific setting (i.e. number of decimals, thousands separator, decimal separator, currency symbols, etc.) based upon my application, not my system's...
1
by: Mythran | last post by:
The NumberDecimalPlaces property is messing me up. I have an arbitrary number, lets say 1234.567. What do I need to do to get the following string: $1 , 234.567...or any decimal value? ...
0
by: Billy | last post by:
Why do I still have to provide a 'String Format' when I have created a NumberFormatInfo object (nfi) that should display what I need. For example I have created a default NumberFormatInfo now when...
3
by: CindyRob | last post by:
I am using .NET framework 1.1 SP1, .NET framework SDK 1.1 SP1, with hotfix 82202, Visual studio .NET 2003 with hotfix 823639. I have generated a proxy class using wsdl.exe from a schema that has an...
11
by: Naeem | last post by:
I have a Javascript function, which changes a text field of a form into a select field. Following is the function function changeStateField() { var myForm =...
1
by: KMEscherich | last post by:
Hi there, am wondering if there is a way to have this code capture 2 dates. You see, I have several fields and some are REQUIRED fields and some are NON-REQUIRED fields. I am attempting to capture...
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...
1
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
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,...
1
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...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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.