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

valid number formats ?

Sam
Hi,
How can I check if a string corresponds to a valid number format ?
e.g :
1,000.00
1.000,00
1 000,00
1'000.00

How to check the above are valid number formats ?

Regards

Nov 21 '05 #1
12 1958
Dim x as Double
If Double.TryParse("1,000.00", Any, CultureInfo.InvariantCulture, x) Then
'it was parsed and x contains the result
Else
'it failed
End If

--
Jonathan Allen
"Sam" <sa**************@voila.fr> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi,
How can I check if a string corresponds to a valid number format ?
e.g :
1,000.00
1.000,00
1 000,00
1'000.00

How to check the above are valid number formats ?

Regards

Nov 21 '05 #2
"Sam" <sa**************@voila.fr> schrieb:
How can I check if a string corresponds to a valid number format ?
e.g :
1,000.00
1.000,00
1 000,00
1'000.00

How to check the above are valid number formats ?


The samples you are giving are concreate instances of certain number
formats. You can use 'Double.TryParse' to check if the string can be parsed
and interpreted as a number.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Sam
Hi,
Thx for your replies. I've tried Jonathan's code:

Dim x As Double
If Double.TryParse(row("Formatting").ToString,
NumberStyles.Any, CultureInfo.InvariantCulture, x) Then
.....

I don't understand why with 1.000,00 it returns false
and with 1,000.00 it returns true. Is 1,000.00 a valid format? I would
have thought it was.....

Nov 21 '05 #4
Sam,
I don't understand why with 1.000,00 it returns false
and with 1,000.00 it returns true. Is 1,000.00 a valid format? I would
have thought it was.....


Do you live in France or are you only using a French email address?

Cor

Nov 21 '05 #5
Sam
Cor,
Why this question ? I'm French but I live in London.
1,000.00 and 1.000,00 to me are both valid but maybe 1.000,00 isn't
valid in the UK ?

Sam

Nov 21 '05 #6
Sam,

Because it is set in a computer, you use either the English language
notation of numbers
1,000.00 or as the other European languages 1.000,00. Your computer sees
that from the settings.

Cor
Nov 21 '05 #7
Sam
Ok, then I can't rely on TryParse, because someone based in the UK or
in the USA could have a machine with European settings, which would
prevent him having a english format.... argh :( this is so annoying!

Nov 21 '05 #8
Sam,

I really am curious how you solve this.

When I type this, than what is the value in your opinion.

1,500

This has nothing to do with programming.

A man cannot be a woman (at the same time).

Cor
Nov 21 '05 #9
Sam
hehe...
I've got a table in my database that has a few fields amongst which, a
Number Format (1,000.00 or 1,000 or whatever), and a Decimal character
(, or . or whatever) so I know what is the decimal part.
1,500 if my Decimal character is , then it means this number is one and
and a half, otherwise it means it is one thousand and five hundred.
I know it 's a arse...

Nov 21 '05 #10
"Sam" <sa**************@voila.fr> schrieb:
1,000.00 and 1.000,00 to me are both valid but maybe 1.000,00 isn't
valid in the UK ?


I don't think that 1.000,00 is valid in the UK, but it's valid in Germany
and Austria.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #11
Sam
No it was a mistake in my sentence. 1.000,00 is not valid in the UK and
1,000.00 is valid.

Nov 21 '05 #12
"Sam" <sa**************@voila.fr> schrieb:
No it was a mistake in my sentence. 1.000,00 is not valid in the UK and
1,000.00 is valid.


ACK.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #13

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

Similar topics

1
by: Piet | last post by:
I am developping a small Python/wxPython app to track expenses. A bunch of information is collected in a wxGUI consisting of text controls, comboboxes and a small grid. Some values are not put in...
3
by: lkrubner | last post by:
Pardon my ignorance on XML DTD's. I'm having trouble reading the one for RSS .91. If I take this page: http://www.bluewallllc.com/hms/rss/page464.xml and I run it through this validator: ...
3
by: andrewcw | last post by:
I save date time into my XML files like this: MesObj.theTime=System.DateTime.Now; "5/4/2004 8:50:30 AM" BUT that string is NOT recognizable as a valid dateTime when the data is read back from...
5
by: Kamaluokeakua | last post by:
I have to write an application that deals with clients in multiple countries. The addresses, phone numbers, country id and currency information has to be stored into a database that allows for the...
4
by: Sam | last post by:
Hi, I've already asked a kind of question like that, but it's a bit different this time. How can I get all of the supported numeric formats by Windows? I want to fill a combobox with those...
1
by: womblesjc | last post by:
I have a data bound Details View control in asp.net 2.0 that formats a phone number. The 'Default Mode' for the control is set to Edit. The phone number field is a template field and I can...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
5
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this:...
6
by: Burkhard Schultheis | last post by:
I've installed a fresh DB2 V9.1 server (Express-C). Now I see, that the number of applications (db2 list applications) is growing all the times when a script is run which makes some database...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
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...

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.