473,473 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Custom format to numeric fields

Hi ,

Not able to figure out the way to format numeric fields.

Code snippet

Dim ColStyle3 As New DataGridTextBoxColumn

With ColStyle3

..MappingName = "TargetQty"

..HeaderText = "Target"

..NullText = "0"

..TextBox.MaxLength = QTYMAXLENGTH (eg. 7)

..Alignment = HorizontalAlignment.Right

..Format = CommonDefinition.CUST_QTY_FORMAT (eg. "###,###,###.00" )

End With

grdTableStyle1.GridColumnStyles.Add(ColStyle3)

This is working fine when the regional Options
General Tab
Your Locale(location) is set to english (United states)
Numbers Tab
digit grouping 123,456,789

Not working in case of
General Tab
Your Locale(location) is set to english (United states)
Numbers Tab
digit grouping 123456789 (without commas)

In this case what is the solution . Application should not take regional
options settings , instead it should take what custom format is done through
configuration file.

================================================== ===================
OR This code is not working when we change regional options number formats
(digit grouping) option
================================================== ===================
' Displays the Numeric formatting examples.

Private Sub LoadNumericFormats()

Dim intNumber As Int32 = 1234567890

Dim sb As New StringBuilder()

strCultureValue = cboCultureInfoNumeric.SelectedValue.ToString

Thread.CurrentThread.CurrentCulture = New CultureInfo(strCultureValue)

sb.Append("When using " & strCultureValue & " CultureInfo, the Integer
1234567890 will format as follows:")

sb.Append(crlf)

sb.Append(crlf)

If optStandardNumeric.Checked Then

With sb

..Append(intNumber.ToString("C"))

..Append(" [Currency]")

..Append(crlf)

..Append(intNumber.ToString("E"))

..Append(" [Scientific (Exponential)]")

..Append(crlf)

..Append(intNumber.ToString("P"))

..Append(" [Percent]")

..Append(crlf)

..Append(intNumber.ToString("N"))

..Append(" [Number]")

..Append(crlf)

..Append(intNumber.ToString("F"))

..Append(" [Fixed-point]")

..Append(crlf)

..Append(intNumber.ToString("X"))

..Append(" [Hexadecimal]")

..Append(crlf)

..Append(crlf)

End With

ElseIf optCustomNumeric.Checked Then

With sb

..Append(intNumber.ToString("###,##"))

..Append(" [###,##]")

..Append(crlf)

..Append(intNumber.ToString("00000"))

..Append(" [00000]")

..Append(crlf)

..Append(intNumber.ToString("(###) ### - ####"))

..Append(" [(###) ### - ##,##]")

..Append(crlf)

..Append(intNumber.ToString("#.##"))

..Append(" [#.##]")

..Append(crlf)

..Append(intNumber.ToString("00.00"))

..Append(" [00.00]")

..Append(crlf)

..Append(intNumber.ToString("#,#"))

..Append(" [#,#]")

..Append(crlf)

..Append(intNumber.ToString("#,,"))

..Append(" [#,,]")

..Append(crlf)

..Append(intNumber.ToString("#.##"))

..Append(" [#.##]")

..Append(crlf)

..Append(intNumber.ToString("#,,,"))

..Append(" [#,,,]")

..Append(crlf)

..Append(intNumber.ToString("#,##0,,"))

..Append(" [#,##0,,]")

..Append(crlf)

..Append(intNumber.ToString("#0.##%"))

..Append(" [#0.##%]")

..Append(crlf)

..Append(intNumber.ToString("0.###E+000"))

..Append(" [0.###E+000]")

..Append(crlf)

..Append(intNumber.ToString("##;(##)"))

..Append(" [##;(##)]")

..Append(crlf)

End With

End If

txtNumeric.Text = sb.ToString

End Sub

Thanks.
Narayan.


Thanks.

Narayan.

Nov 20 '05 #1
0 1679

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

Similar topics

6
by: Willem-Jan Selen | last post by:
Hie everybody, I have a problem with the following, I have a table with a row containing numbers with 2 decimal places. I want to count the sum of these numbers but my valuw returned is far...
2
by: Betrock | last post by:
This is probably very simple, but I just can't see my way thru it..... Short version: keyed values(numeric)in a lookup table are stored in a main table. They are displayed as text values - the...
22
by: TC | last post by:
I have an Access database application with a lot of custom row functions written in VBA. In other words, a lot of queries contain calculated fields which use functions defined in the modules. I...
2
by: Scott M. Lyon | last post by:
I currently am working on a VB.NET application that imports data from an Excel spreadsheet that the customer filled in. I used the following code to use ODBC to read the data from the...
2
by: Pipo | last post by:
Nobody knows how to get the values provided in the client can be read in the user-control? If have made a Web Custom Control with 2 textboxes and 1 dropdownlist. The user fills in my control (the...
10
by: Badis | last post by:
Hi Guys, I'm trying to retrieve data defined as Numeric in Cache database and display it in a textbox but it's giving me this error: "Input string was not in a correct format" Cheers.
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
2
Pittaman
by: Pittaman | last post by:
Hello I am creating some crystal reports (for visual studio 2005) based on the content of certain .NET objects. I'm doing this in .NET 2.0. For one of them I'm using a Cross-table to summarize...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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,...
1
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...
0
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...
0
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...
0
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 ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.