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

International Number Formatting

Hi

I have an app where I have to deal with both Spanish & American formatting.
I have a string that represents a number that I need to convert to Int32
before I enter it in the database. The string can be any number, for
example, "1,355" (American style) or "1.355" (Spanish style) . I know could
use the Replace method and "strip" the number string of "." or the "," then
convert what is left to Int32.

But I thought maybe there is a better way using the CultureInfo class that
simply converts any culture number sting to a number. However, I'm having
problems figuring this one out.

Can anyone lend a helping hand?

TIA

Steve
Nov 20 '05 #1
2 1667
Hi,

Dim strEng As String = "1,355"
Dim strSpanish As String = "1.355"

Dim intEng As Integer = Integer.Parse(strEng,
Globalization.NumberStyles.AllowThousands, New
System.Globalization.CultureInfo("en-US"))

Dim intSpanish As Integer = Integer.Parse(strSpanish,
Globalization.NumberStyles.AllowThousands, New
System.Globalization.CultureInfo("es-ES"))

Trace.WriteLine(String.Format("{0} = {1}", strEng, intEng))
Trace.WriteLine(String.Format("{0} = {1}", strSpanish, intSpanish))
Ken
--------------------------
"Steve Peterson" <sp*******@arrakis.es> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...
Hi

I have an app where I have to deal with both Spanish & American
formatting.
I have a string that represents a number that I need to convert to Int32
before I enter it in the database. The string can be any number, for
example, "1,355" (American style) or "1.355" (Spanish style) . I know
could
use the Replace method and "strip" the number string of "." or the ","
then
convert what is left to Int32.

But I thought maybe there is a better way using the CultureInfo class that
simply converts any culture number sting to a number. However, I'm having
problems figuring this one out.

Can anyone lend a helping hand?

TIA

Steve

Nov 20 '05 #2
Thanks Ken

That did the trick!

Steve
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
Hi,

Dim strEng As String = "1,355"
Dim strSpanish As String = "1.355"

Dim intEng As Integer = Integer.Parse(strEng,
Globalization.NumberStyles.AllowThousands, New
System.Globalization.CultureInfo("en-US"))

Dim intSpanish As Integer = Integer.Parse(strSpanish,
Globalization.NumberStyles.AllowThousands, New
System.Globalization.CultureInfo("es-ES"))

Trace.WriteLine(String.Format("{0} = {1}", strEng, intEng))
Trace.WriteLine(String.Format("{0} = {1}", strSpanish, intSpanish))

Ken
--------------------------
"Steve Peterson" <sp*******@arrakis.es> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...
Hi

I have an app where I have to deal with both Spanish & American
formatting.
I have a string that represents a number that I need to convert to Int32
before I enter it in the database. The string can be any number, for
example, "1,355" (American style) or "1.355" (Spanish style) . I know
could
use the Replace method and "strip" the number string of "." or the ","
then
convert what is left to Int32.

But I thought maybe there is a better way using the CultureInfo class that simply converts any culture number sting to a number. However, I'm having problems figuring this one out.

Can anyone lend a helping hand?

TIA

Steve


Nov 20 '05 #3

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

Similar topics

9
by: Jenta | last post by:
A World Beyond Capitalism 2005, An Annual International Multiracial Alliance Building Peace Conference Is Accepting Proposals... ...and Online Registration is now available if you plan to table...
0
by: MarionEll | last post by:
XML 2004 Shows International Side to XML Alexandria, Va. - Oct. XX, 2004 - IDEAlliance, a leading industry association dedicated to fostering XML and other information technology standards, today...
0
by: Yeongja_Choi | last post by:
How Dare Could America Industrial Property Office Be In Conspiracy With Jungang International Patent Office To Make An Extravagant International Crime ? Currently a Korean party now holds the...
0
by: MarionEll | last post by:
XML 2004 Shows International Side to XML Alexandria, Va. - Oct. XX, 2004 - IDEAlliance, a leading industry association dedicated to fostering XML and other information technology standards, today...
1
by: cab2 | last post by:
We currently have an application built in Access that takes in a csv file using docmd.transfertext. We allow users to export their data to a file for later use (csv format). Users are also...
1
by: Joerg | last post by:
I am in the process of creating an international GUI application with C# on ..NET1.1 (Win2k), which is supposed to implement a particular look/design. In order to achieve this, I plan amongst...
6
by: tatata9999 | last post by:
Hi all, I have this simple time management tool designed and developed. And based on a very thoughtful and kind Frenchman's input I've extended its support to international (support all time...
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...
3
by: Nightcrawler | last post by:
I have a website that does the following: 1. it accepts a keyword through a textbox in the UI 2. once the submit button is clicked it goes out and spiders a few websites using the keyword...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...
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...

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.