473,795 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1681
Hi,

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

Dim intEng As Integer = Integer.Parse(s trEng,
Globalization.N umberStyles.All owThousands, New
System.Globaliz ation.CultureIn fo("en-US"))

Dim intSpanish As Integer = Integer.Parse(s trSpanish,
Globalization.N umberStyles.All owThousands, New
System.Globaliz ation.CultureIn fo("es-ES"))

Trace.WriteLine (String.Format( "{0} = {1}", strEng, intEng))
Trace.WriteLine (String.Format( "{0} = {1}", strSpanish, intSpanish))
Ken
--------------------------
"Steve Peterson" <sp*******@arra kis.es> wrote in message
news:%2******** *********@TK2MS FTNGP10.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***@bellsout h.net> wrote in message
news:eM******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

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

Dim intEng As Integer = Integer.Parse(s trEng,
Globalization.N umberStyles.All owThousands, New
System.Globaliz ation.CultureIn fo("en-US"))

Dim intSpanish As Integer = Integer.Parse(s trSpanish,
Globalization.N umberStyles.All owThousands, New
System.Globaliz ation.CultureIn fo("es-ES"))

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

Ken
--------------------------
"Steve Peterson" <sp*******@arra kis.es> wrote in message
news:%2******** *********@TK2MS FTNGP10.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
2345
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 and participate in the International Grassroots Exhibition: http://www.lfhniivaaaa.info/awbcgrassrootsofpeace We would greatly like some proposals from all people worldwide, especially
0
1619
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 announced that XML Conference and Exposition 2004 will feature more than 40 international speakers and exhibitors showcasing XML technologies and solutions from around the globe. XML 2004 is slated for November 15-19 at the Marriott Wardman Park...
0
1701
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 American patent 4919933, the Taiwanese patent 37414, the Japanese patent 2733523 and a Korean patent 044435 through The Korean Jungang International Patent Law Office(Address : 5th Floor, Jae Insurance Bld, #80, Susong-Dong, Jongro-Gu, Seoul, the...
0
1446
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 announced that XML Conference and Exposition 2004 will feature more than 40 international speakers and exhibitors showcasing XML technologies and solutions from around the globe. XML 2004 is slated for November 15-19 at the Marriott Wardman Park...
1
2165
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 allowed to re-import their archived data. This all works fine, until we have to update the application for international users. The original csv files sent to users contain dates and numbers in US format. However, once imported, the numbers appear...
1
2386
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 others to define a certain font (MS Arial Unicode) for the user controls, and provide custom controls which have the font property fixed set to this font. The application is supposed to be used in different countries (including China), so I wonder...
6
2344
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 zones), however, I'm not 100% sure if its global time zone support is perfectly correct. Please try it and offer feedback, URL, http://www.mytata.net/ tia.
2
11919
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 the information of a bunch of objects. The actual data is numeric. Since these reports are meant to be flexible number formatting must be configured as defined by the requirements. For example, sometimes the values will have to be rounded to 5...
3
1498
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 supplied 3. it converts the returned html to xml 4. it uses LINQ to query the html page and stores the results in a database table 5. it then pulls the results from the database using a LINQ query ad displays them on a webpage
0
9522
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
10448
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
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...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7544
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
5440
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
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.