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

Home Posts Topics Members FAQ

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 2203
Precision isn't necessarily the same as decimal places. What db is it? SQL /
Oracle / Jet?

"Robin Tucker" <id************ *************@r eallyidont.com> wrote in
message news:cu******** ***********@new s.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.C om> wrote in message
news:ZX******** *********@newsf e5-gui.ntli.net...
Precision isn't necessarily the same as decimal places. What db is it? SQL
/ Oracle / Jet?

"Robin Tucker" <id************ *************@r eallyidont.com> wrote in
message news:cu******** ***********@new s.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 DataGridTextBox Column object that will format
the display. The display format string you are looking for is "0.0000"

Hope it helps
Chris

"Robin Tucker" <id************ *************@r eallyidont.com> wrote in
message news:cu******** ***********@new s.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.C om> wrote in message
news:ZX******** *********@newsf e5-gui.ntli.net...
Precision isn't necessarily the same as decimal places. What db is it?
SQL / Oracle / Jet?

"Robin Tucker" <id************ *************@r eallyidont.com> wrote in
message news:cu******** ***********@new s.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 numberformatinf o. 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.Bindin gContext(DataGr id1.DataSource) ,
CurrencyManager )

Dim pd As System.Componen tModel.Property Descriptor =
cm.GetItemPrope rties()("Qty")

Dim ni As New System.Globaliz ation.NumberFor matInfo

ni.NumberDecima lDigits = 3

Dim colQty As New DataGridTextBox Column(pd, "f")

With colQty

..MappingName = "Col1"

..HeaderText = "Qty"

..Width = 75

..FormatInfo = ni

End With

Ken

------------------------------
"Robin Tucker" <id************ *************@r eallyidont.com> wrote in
message news:cu******** ***********@new s.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 theStringToDisp lay as String = "######." + "0".PadRight(my Precision,
"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******** ********@TK2MSF TNGP12.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 DataGridTextBox Column object that will
format the display. The display format string you are looking for is
"0.0000"

Hope it helps
Chris

"Robin Tucker" <id************ *************@r eallyidont.com> wrote in
message news:cu******** ***********@new s.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.C om> wrote in message
news:ZX******** *********@newsf e5-gui.ntli.net...
Precision isn't necessarily the same as decimal places. What db is it?
SQL / Oracle / Jet?

"Robin Tucker" <id************ *************@r eallyidont.com> wrote in
message news:cu******** ***********@new s.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
1406
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 those keys. The status bar tells me "The key combination (Ctrl+k, Ctrl+D) is not a command." Weird... I then check the Edit menu->Advanced. Format Selection is there, but Format Document isn't. Ok, so I go into Customize... verify that the...
3
11740
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/ Exception: Type= System.FormatException Message: Input string was not in a correct format. StackTrace: at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
16
4009
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 date format of "mm/dd/yy" For example the barcode contains "112303" and I want to format it to display "11/23/03" If I use the microsoft.visualbasic.strings.format with a format string of "##/##/##" or "00/00/00" I get the format string in the...
5
2161
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 date from Table 1 into
3
4438
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 places, for example .0397 how do I use the format statement and get this result?
0
1229
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" format. I want to use the format of, for an example, "5/23/2007 12:35:58 PM", to include hour/minute/second to display one column (while keeping the format of the other column as it is). Anyone can advise me on how to
4
3256
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 want to use the format of, for an example, "5/23/2007 12:35:58 PM", to include hour/minute/second. Anyone can advise me on how to change the format?
2
4718
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" I tried datetime.parseexact but could not find the definition for the appropriate format string. This would be a very useful tool fo me. Any ideas,please?
14
15310
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 ValidationExpression="//", but user can write date "31/02/2000" and validator says that it is correct (everybody know that Febuary has 28 or 29 days).
0
8168
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
8614
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
8330
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
7153
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
6107
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...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.