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!) 5 2143
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!)
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!)
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!)
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!)
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!)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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/...
|
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...
|
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...
|
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...
|
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"...
|
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...
|
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"
...
|
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...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |