473,407 Members | 2,598 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,407 software developers and data experts.

Precision with "Format".

My database has a [Precision] column for numeric data items. How can I use
this number in the "format" command, such that for, say precision 2, I get
numbers like 2011.01 or 2387.00 and for 4 I would get 2011.0100 or
2387.0000?

(simple question I know!)
Nov 21 '05 #1
5 2188
Precision isn't necessarily the same as decimal places. What db is it? SQL /
Oracle / Jet?

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...
My database has a [Precision] column for numeric data items. How can I
use this number in the "format" command, such that for, say precision 2, I
get numbers like 2011.01 or 2387.00 and for 4 I would get 2011.0100 or
2387.0000?

(simple question I know!)

Nov 21 '05 #2
I'm using SQL Server. I don't mean precision, I mean "displayed decimal
places". My "displayed decimal places" is a field, when its 2, I just want
to show aa.bb, when its 3, aa.bbb (or aaaaaaaaaa.bbb) etc. Sure this is
probably quite simple using "Format"?

"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ZX*****************@newsfe5-gui.ntli.net...
Precision isn't necessarily the same as decimal places. What db is it? SQL
/ Oracle / Jet?

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...
My database has a [Precision] column for numeric data items. How can I
use this number in the "format" command, such that for, say precision 2,
I get numbers like 2011.01 or 2387.00 and for 4 I would get 2011.0100 or
2387.0000?

(simple question I know!)


Nov 21 '05 #3
When you say "My "displayed decimal places" is a field" what are you
displaying it in? A datagrid or a textbox? The formatting of the display
on the client has nothing to do with the database. Look at the
String.Format command if using a textbox. If you are using a datagrid there
is a format property on the DataGridTextBoxColumn object that will format
the display. The display format string you are looking for is "0.0000"

Hope it helps
Chris

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...
I'm using SQL Server. I don't mean precision, I mean "displayed decimal
places". My "displayed decimal places" is a field, when its 2, I just
want to show aa.bb, when its 3, aa.bbb (or aaaaaaaaaa.bbb) etc. Sure this
is probably quite simple using "Format"?

"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ZX*****************@newsfe5-gui.ntli.net...
Precision isn't necessarily the same as decimal places. What db is it?
SQL / Oracle / Jet?

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...
My database has a [Precision] column for numeric data items. How can I
use this number in the "format" command, such that for, say precision 2,
I get numbers like 2011.01 or 2387.00 and for 4 I would get 2011.0100 or
2387.0000?

(simple question I know!)



Nov 21 '05 #4
Hi,

Use a numberformatinfo. This is how to get a datagrid to display 3
digits after the decimal. Place this in your tablestyle for the grid.

Dim cm As CurrencyManager = CType(Me.BindingContext(DataGrid1.DataSource),
CurrencyManager)

Dim pd As System.ComponentModel.PropertyDescriptor =
cm.GetItemProperties()("Qty")

Dim ni As New System.Globalization.NumberFormatInfo

ni.NumberDecimalDigits = 3

Dim colQty As New DataGridTextBoxColumn(pd, "f")

With colQty

..MappingName = "Col1"

..HeaderText = "Qty"

..Width = 75

..FormatInfo = ni

End With

Ken

------------------------------
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...
My database has a [Precision] column for numeric data items. How can I use
this number in the "format" command, such that for, say precision 2, I get
numbers like 2011.01 or 2387.00 and for 4 I would get 2011.0100 or
2387.0000?

(simple question I know!)

Nov 21 '05 #5
Yes, I worked it out something like this:

Dim theStringToDisplay as String = "######." + "0".PadRight(myPrecision,
"0"c)

So I have a variable "displayed decimal places" according to the value of
the precision column in the database ( there is a column called [Precision]
(a tinyint) that tells me how many decimal places the user wants with his
value - we use this because I am sending up values to another piece of
custom hardware which requires this information).

Thanks.

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
When you say "My "displayed decimal places" is a field" what are you
displaying it in? A datagrid or a textbox? The formatting of the display
on the client has nothing to do with the database. Look at the
String.Format command if using a textbox. If you are using a datagrid
there is a format property on the DataGridTextBoxColumn object that will
format the display. The display format string you are looking for is
"0.0000"

Hope it helps
Chris

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...
I'm using SQL Server. I don't mean precision, I mean "displayed decimal
places". My "displayed decimal places" is a field, when its 2, I just
want to show aa.bb, when its 3, aa.bbb (or aaaaaaaaaa.bbb) etc. Sure
this is probably quite simple using "Format"?

"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ZX*****************@newsfe5-gui.ntli.net...
Precision isn't necessarily the same as decimal places. What db is it?
SQL / Oracle / Jet?

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...
My database has a [Precision] column for numeric data items. How can I
use this number in the "format" command, such that for, say precision
2, I get numbers like 2011.01 or 2387.00 and for 4 I would get
2011.0100 or 2387.0000?

(simple question I know!)



Nov 21 '05 #6

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

Similar topics

0
by: JD | last post by:
While reading through the "shortcuts" topic in the help, I saw that there's a "Format Document" option - CTRL+K, CTRL+D. Cool... so I go into a .cs source file (this is a winforms project) and hit...
3
by: dan | last post by:
I am using VB.NET 2003 and SQL Server 2000. The program uses ADO.NET . The following instruction: Me.cd_insertDataRecord.ExecuteNonQuery() throws this exception: ">>>ProcessDataRecord/...
16
by: Al Reid | last post by:
First, I'm using vb2005. I have a string that is read from a barcode reader into a TextBox. The string is 6 characters long and represents a date (mmddyy). I want to display it to the user in a...
5
by: veaux | last post by:
I'm thinking this is easy but can't get it. I have a table with following: Table1 Date 1/1/2007 Table2 Type 0107 (This is MMYY of above) So I'm having trouble using a query to turn the...
3
by: shill57957 | last post by:
I have a query: SELECT .AH_TICKNO, Format((.AH_AMOUNT-.AH_TRNAMT)/.AH_AMOUNT,"Percent") AS DIF INTO FROM ; I dont want to format as a percent, I want it to go into the table with 4 decimal...
0
by: Curious | last post by:
Hi, I have two columns in a grid defined as DateTime type. Currently, they're both displayed in the format of "5/23/2007", for an example. It seems that they're using the default "short date"...
4
by: Curious | last post by:
Hi, I have a column in a grid defined as DateTime type. Currently, it's displayed in the format of "5/23/2007", for an example. It seems that it's using the default "short date" format. I...
2
by: stainless | last post by:
I know this is probably simple but I cannot find a method of converting a date string into a format that matches the DatePicker format in C# eg string "20080131" converted to "31 January 2008" ...
14
by: | last post by:
Hi, I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy". I would like to validate if the date is realy correct. I used RegularExpressionValidator with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...
0
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...

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.