473,624 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Format string decimal point problem


I am trying to apply the following easy-to-state formatting rule to
display a number:

- If the number is positive or negative, display it in the 'default'
way
- If the number is zero, the output should be an empty string

Now I know this is trivial to code, but the elegant solution would be
passing a custom format string to ToString(). The problem is, I can't
make one that works: There doesn't seem to be a way to combine the
'pre-defined' numeric formats with the user-defined format idea of
semi-colon-delimited differing formats for positive;negati ve;zero
inputs.

I tried "#########.#### ##;-######.#####;" which *almost* works, except
that for whole-number inputs it still displays a decimal point. There
doesn't seem to be a 'conditional decimal point' formatting character
in the same way that # is a 'conditional digit' formatting character.

As I said, this isn't desperately important, but I would be interested
to learn if I am missing something.
--
Larry Lard
Replies to group please

Nov 21 '05 #1
6 1671
Larry,

You mean that you make work from
\\\
a = ""
if b <> 0 then a = b.tostring
///

I never take the time to think about those things to much

I check the characters I have to type for that mostly to see what I take.

:-)

Cor
Nov 21 '05 #2
Cor Ligthert wrote:
Larry,

You mean that you make work from
\\\
a = ""
if b <> 0 then a = b.tostring
///


That doesn't insert the thousand seperators he wants AFAIK

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #3
Rinze,

Are you sure is there not a default toString format what you can set in the
language-culture settings.

http://msdn.microsoft.com/library/de...classtopic.asp

Oh I see Fries is not a culture.

:-))))

Cor
Nov 21 '05 #4
Sorry,

Has not a culture

:-)

Cor
Nov 21 '05 #5

Cor Ligthert wrote:
Larry,

You mean that you make work from
\\\
a = ""
if b <> 0 then a = b.tostring
///

I never take the time to think about those things to much


I do :) Elegance above all else!
--
Larry Lard
Replies to group please

Nov 21 '05 #6
Cor Ligthert wrote:
Sorry,

Has not a culture

:-)

Cor


Luckily I'm not from Friesland, only my name is :P

Anyhow, I haven't played around with the culture settings that's why I
added the AFAIK (As Far As I Know). I guess I'll have to look into that.

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #7

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

Similar topics

10
3272
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: http://www.ipwebdesign.net/kaelisSpace/useful_tableSort.html This works great except it doesn't sort my UK formatted dates properly, and I end up with something like this: Birth Date (dd/mm/yyyy)
6
30156
by: J | last post by:
Would anyone know if there a type tag to format a double? I have f for floating point, but cannot find one for double.
1
15470
by: Mike MacSween | last post by:
This looks like a bug to me. I have an expression on a report: =Format(Sum((**)*(/)),"0.00") Score is byte PercentOfGrade is double PropDegree is single ModuleCats is byte
2
5954
by: Claus Haslauer | last post by:
Hi, I want to create a crosstab query that looks like this Date | Elevation 1 | Elevation 2 | ... ______________________________________________________________________ Date 1 | xx.y | xx.y Date 2 | xx.y | xx.y xx.y are measurements taken at different dates at different elevations. xx.y and elevation happen to be in the same format (meters).
6
2606
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 3.21 will display 3.21
7
6490
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 where I can look up explaination on the String.Format, the format string part like "("{0:.#0}". What's the trailing 0 and what is that "0:" means? I assume the "#" is the place holder character for th value obtain after the comma in the code. ...
6
3829
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The first two columns are pretty much text column, but subsequent columns 1-12 are numerical. I'm trying to get the thousand separator to work. Any ideas?
11
2242
by: RipperT | last post by:
Don't know if this group covers web apps, but here goes. In VS 2005, I am trying to get variables to hold thier values during postback from the server. I convert a text box's user-keyed value to an integer and assign it to a module level variable, then convert the variable and assign it to a hidden text box, setting it's EnableViewState to true so it returns with the reload. Then in the form's load event, I attempt to convert the contents...
7
5471
by: Tony Girgenti | last post by:
Hello. Trying to develop VS2005, SP1 windows form VB program. When i try a statement like below and the data is "24.95", without the quotes of course, regPriceString equals "000000000025+" . regPriceString = String.Format("{0:000000000000+}", merchandiseDataRow.Item("RegPrice"))
0
8233
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8619
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7158
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6108
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.