I'm monitoring key presses in an edit box on a pocket pc device.
It's for floating point numbers and Im allowing '-', '0'..'9', #8 plus
decimal point character.
Ive a function that should return a char representing the decimal point for
this locale.
Not knowing what I was doing on .net, I did a google and came up with some
code that I changed as follows.
It looks really ugly and I wondered if I needed to do all this to read back
a decimal separator value. Please would someone change my code. I don't know
if it works, it returns a '.' OK for my english pocketpc, but I wouldn't
know how to set up
pocketpc to change locale for test purposes.
public static char DecimalSeparato r()
{
char c;
System.Globaliz ation.CultureIn fo ci =
System.Globaliz ation.CultureIn fo.CurrentUICul ture;
System.Globaliz ation.NumberFor matInfo ni =
(System.Globali zation.NumberFo rmatInfo)
ci.NumberFormat .Clone();
c = (ni.NumberDecim alSeparator.ToC harArray())[0];
return c;
} 2 11043
Hi Claire,
Well, you could declare
using System.Globaliz ation;
and save a couple of words, and put it all on a single line.
using SystemGlobaliza tion;
public static char DecimalSeparato r()
{
return CultureInfo.Cur rentCulture.Num berFormat.Numbe rDecimalSeparat or.ToCharArray( )[0];
}
--
Happy coding!
Morten Wennevik [C# MVP]
Haven't tested yet, but thanks Morten This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ordz |
last post by:
I want to write a program that will take a decimal with up to 4 places
and convert it to 1/16 ths. I can sort of do that with:
n = 375 * 16 / 1000
Print n; "/16"
I am planning to use an input box to enter the number with no decimal
point.
But I don't know how to get a count of the digits in the denominator.
I will also round off any...
|
by: SAN CAZIANO |
last post by:
i have to do in the onkeypress or in onchange the float (real) field
validation
I try something:
function ValidaCampo(nomeCampo,TotInteri,TotDecimali)
{
DecimalPos=NomeCampo.value.Indexof(',');
Lungh=TotInteri+TotDecimali+1; //sum the ineger + decimal +
decimal separator
|
by: John Bowman |
last post by:
Hi,
A couple Q's , so I've come to the experts<g>.
1) I need a definitive answer to the following debate. I've got a couple
developers who disagree on the following question. We've got an XML file of
numerical data results where it could contain values such as:
<RESULT>0.12345</RESULT> when created in English, but it could contain:...
|
by: GP |
last post by:
Decimal.Parse("100,5") returns 1005 when it should throw an
InvalidFormatException. The locale is US therefore the "," is a thousand
separator. Even if the parser confused it for the decimal separator it
should return 100.5. Maybe this bug is already logged but I couldn't find it
on MSDN.
--
Best regards,
Gianluca Pivato
--
|
by: trawlerman |
last post by:
Hi all,
C# newbie after migrating from VB. I wish to have only valid numbers
entered into a txtbox . i.e only one decimal point.
///////////////////My VB code for this is:
Private Sub txtGcost_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57, 8
Case 46
If InStr(txtGcost.Text, ".") 0 Then
| |
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?
-----------------------------------------------------------------------
When formatting money for example, to format 6.57634 to
6.58, 6.5 to 6.50, and 6 to 6.00?
Rounding of x.xx5 is...
|
by: apattin |
last post by:
Hi all,
I have a table containing MEASURE DOUBLE. I want to
SELECT measure FROM mytable WHERE <condition>
If measure = 1860.45, I get: '1,860.45'. How can I strip the comma? I
tried:
DECIMAL(measure,20,5) still has the comma
|
by: pax |
last post by:
Hello there!
Here is my problem, in the simplest scenario:
- an Access 2000 format database (created with Access 2003)
- a simple table that contains one single field defined as Number, Decimal,
18,2
- VS2005 standard, C#
- a data source / dataset that cotains that simple Access table
- a DataGridView, created by drag and drop, with all...
|
by: boder |
last post by:
I've set US locale with ',' (comma) as a decimal separator.
My code :
var xmlObject = new ActiveXObject("MSXML2.DOMDocument.3.0");
xmlObject.setProperty("SelectionLanguage", "XPath");
var datasetNode = xmlObject.createElement("dataset");
datasetNode.setAttribute("name", "test");
var recordNode =...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |