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

Decimal formatting

Vik
Dim Dec As Decimal, Str1, Str2 As String

Dec = 1

Str1 = Dec.ToString ' Str1 = "1"

Dec = "1.0000"

Str2 = Dec.ToString("G") ' Str2 = "1.0000"

Is it possible to format Str2 so that Str2 = "1"?

Thanks.
Nov 19 '05 #1
3 1259
Str2 = Dec.ToString("#,##0")

"Vik" wrote:
Dim Dec As Decimal, Str1, Str2 As String

Dec = 1

Str1 = Dec.ToString ' Str1 = "1"

Dec = "1.0000"

Str2 = Dec.ToString("G") ' Str2 = "1.0000"

Is it possible to format Str2 so that Str2 = "1"?

Thanks.

Nov 19 '05 #2
Vik
Thank you for reply.

Sorry, my question was not quite correct. I wonder if there is one format
code that provides the following:

Dec = 1.1234
Str2 = Dec.ToString(Some format) ' Str2 = "1.1234"
Dec = "1.0000"
Str2 = Dec.ToString(The same format as above) ' Str2 = "1"

Actually a program doesn't assign "1.0000" to Dec. The program reads data
from a decimal column in a SQL Server database.

Viktor

"Waran" <Wa***@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
Str2 = Dec.ToString("#,##0")

"Vik" wrote:
Dim Dec As Decimal, Str1, Str2 As String

Dec = 1

Str1 = Dec.ToString ' Str1 = "1"

Dec = "1.0000"

Str2 = Dec.ToString("G") ' Str2 = "1.0000"

Is it possible to format Str2 so that Str2 = "1"?

Thanks.

Nov 19 '05 #3
Dim dec As Decimal, fmt As String
fmt = "0.####"
dec = 1.242
System.Diagnostics.Debug.WriteLine(dec.ToString(fm t))
dec = 1
System.Diagnostics.Debug.WriteLine(dec.ToString(fm t))
--------
Output window:
1.242
1
Mike

Nov 19 '05 #4

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

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
2
by: probashi | last post by:
Hi, I am trying to the following: String s = "( 54.05)"; decimal d = decimal.Parse(s); when s = "( 54.05)" I what the value -54.05 and s = " 54.05" I what the value 54.05
2
by: KB | last post by:
Hi guys, In my DataGrid I have a column that displays decimal values as currency ( I set the Data Formatting expression of that column to {0:C}). So the actual string displayed in the grid looks...
3
by: JenHu | last post by:
Hi all, I have to read from a text file and generate values and insert to database. But first of all, when the text file contains '0000000000', I received a sEfundAmt value = 0D instead of 0.0...
8
by: G.Ashok | last post by:
Hi, I have created CultureInfo object and specified required digit grouping in it. The one of the overloaded ToString methods of Decimal type has parameters to format the value with required...
6
by: Larry Lard | last post by:
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...
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...
5
by: Stefantastisk | last post by:
Hey there, Anyone knows a clever method for knowing the length of the digit after a decimal point in a standard C# decimal value, WITHOUT use of any string formatting. Example: 5231,12231 <-...
3
by: zgfareed | last post by:
My program converts decimal numbers from to binary and hexadecimal. I am having trouble with my output which is supposed to be in a certain format. Binary needs to be in the format of XXXX XXXX...
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: 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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.