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

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;negative;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 1660
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
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: ...
6
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
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
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...
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...
7
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...
6
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...
11
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...
7
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+" . ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.