Hi, are there any function in C# to validate that the value from a textbox
to be numeric ?

Thanks in advance.

Re: IsNumeric validation Compact Framework 2.0 by Chris

Chris
Thu May 08 10:07:00 CDT 2008

Depending on your needs, most of the Parse functions would work:

int myval = int.Parse(textBox.Text);
float myval = float.Parse(textBox.Text);

etc.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

"Malani Czornon" <pusy06@aol.com> wrote in message
news:u$iM8oRsIHA.4840@TK2MSFTNGP05.phx.gbl...
> Hi, are there any function in C# to validate that the value from a textbox
> to be numeric ?
>
> Thanks in advance.
>



Re: IsNumeric validation Compact Framework 2.0 by Malani

Malani
Thu May 08 11:39:11 CDT 2008

Thanks Chirs for your reply, but Parse doesn´t return true or false.... it
returns an expection....
I need to get a bool value...



"Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com> escribió en el mensaje
news:Otvdj0RsIHA.548@TK2MSFTNGP06.phx.gbl...
> Depending on your needs, most of the Parse functions would work:
>
> int myval = int.Parse(textBox.Text);
> float myval = float.Parse(textBox.Text);
>
> etc.
>
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Giving back to the embedded community
> http://community.OpenNETCF.com
>
> "Malani Czornon" <pusy06@aol.com> wrote in message
> news:u$iM8oRsIHA.4840@TK2MSFTNGP05.phx.gbl...
>> Hi, are there any function in C# to validate that the value from a
>> textbox to be numeric ?
>>
>> Thanks in advance.
>>
>
>



Re: IsNumeric validation Compact Framework 2.0 by Chris

Chris
Thu May 08 11:46:28 CDT 2008

I see. That's way more complex then.

public bool IsInt(string value)
{
try { int.Parse(value); }
catch { return false; }
return true;
}

Close to quantum physics.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

"Malani Czornon" <pusy06@aol.com> wrote in message
news:%23F6hMoSsIHA.4544@TK2MSFTNGP04.phx.gbl...
> Thanks Chirs for your reply, but Parse doesn´t return true or false.... it
> returns an expection....
> I need to get a bool value...
>
>
>
> "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com> escribió en el mensaje
> news:Otvdj0RsIHA.548@TK2MSFTNGP06.phx.gbl...
>> Depending on your needs, most of the Parse functions would work:
>>
>> int myval = int.Parse(textBox.Text);
>> float myval = float.Parse(textBox.Text);
>>
>> etc.
>>
>>
>> --
>>
>> Chris Tacke, Embedded MVP
>> OpenNETCF Consulting
>> Giving back to the embedded community
>> http://community.OpenNETCF.com
>>
>> "Malani Czornon" <pusy06@aol.com> wrote in message
>> news:u$iM8oRsIHA.4840@TK2MSFTNGP05.phx.gbl...
>>> Hi, are there any function in C# to validate that the value from a
>>> textbox to be numeric ?
>>>
>>> Thanks in advance.
>>>
>>
>>
>
>



Re: IsNumeric validation Compact Framework 2.0 by Serge

Serge
Thu May 08 16:42:40 CDT 2008

Chris,

Beware of quantum physics. This stuff is way too unstable to be used in a
beginner's program: Catching the exception is somehow measuring it, which
would bring Heisenberg and his uncertainty principle into the game. From
there on, false would no longer be sure whether he's actually as false as
that, which would probably lead to more exceptions being thrown randomly.
You'd probably need to include some statistical physics library into your
program to analyze the spectrum of these exceptions. Monte Carlo would
surely help. And that's where it hurts: Do Monte Carlo implementations
internally use bool results? Better not because they'd start colliding into
these other bools they are evaluating, which might actually lead to a bool
fission reaction. Which by globally destroying the whole binary system would
somehow solve the OP's concern the hard way (lack of any form of computer, I
mean). And all we wanted to do is to know if a string can be converted to an
int. I warned you: Unstable stuff, this quantum physics.

BTW, do you think this could be considered experimental evidence of the
butterfly effect? Someone should give it a try some day.

Serge.
http://www.apptranslator.com



"Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com> wrote in message
news:OExJIsSsIHA.5872@TK2MSFTNGP04.phx.gbl...
>I see. That's way more complex then.
>
> public bool IsInt(string value)
> {
> try { int.Parse(value); }
> catch { return false; }
> return true;
> }
>
> Close to quantum physics.
>
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Giving back to the embedded community
> http://community.OpenNETCF.com
>
> "Malani Czornon" <pusy06@aol.com> wrote in message
> news:%23F6hMoSsIHA.4544@TK2MSFTNGP04.phx.gbl...
>> Thanks Chirs for your reply, but Parse doesn´t return true or false....
>> it returns an expection....
>> I need to get a bool value...
>>
>>
>>
>> "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com> escribió en el mensaje
>> news:Otvdj0RsIHA.548@TK2MSFTNGP06.phx.gbl...
>>> Depending on your needs, most of the Parse functions would work:
>>>
>>> int myval = int.Parse(textBox.Text);
>>> float myval = float.Parse(textBox.Text);
>>>
>>> etc.
>>>
>>>
>>> --
>>>
>>> Chris Tacke, Embedded MVP
>>> OpenNETCF Consulting
>>> Giving back to the embedded community
>>> http://community.OpenNETCF.com
>>>
>>> "Malani Czornon" <pusy06@aol.com> wrote in message
>>> news:u$iM8oRsIHA.4840@TK2MSFTNGP05.phx.gbl...
>>>> Hi, are there any function in C# to validate that the value from a
>>>> textbox to be numeric ?
>>>>
>>>> Thanks in advance.
>>>>
>>>
>>>
>>
>>
>
>


Re: IsNumeric validation Compact Framework 2.0 by Manoj

Manoj
Fri May 09 03:57:37 CDT 2008

On May 8, 7:46=A0am, "Malani Czornon" <pus...@aol.com> wrote:
> Hi, are there any function in C# to validate that the value from a textbox=

> to be numeric ?
>
> Thanks in advance.

Have you tried int.tryParse

int i =3D -1;
bool isNumeric =3D int.tryParse(textBox1.Text, out i);

If isNumeric is true then i holds numeric value.

Re: IsNumeric validation Compact Framework 2.0 by Serge

Serge
Fri May 09 04:17:57 CDT 2008

No TryParse in CF :-(

HTH,

Serge.
http://www.apptranslator.com - Localization tool for your applications


"Manoj Kumar" <manjok@gmail.com> wrote in message
news:0c858b4e-9fc0-4d01-8aec-5d0ca2d7e414@n1g2000prb.googlegroups.com...
On May 8, 7:46 am, "Malani Czornon" <pus...@aol.com> wrote:
> Hi, are there any function in C# to validate that the value from a textbox
> to be numeric ?
>
> Thanks in advance.

Have you tried int.tryParse

int i = -1;
bool isNumeric = int.tryParse(textBox1.Text, out i);

If isNumeric is true then i holds numeric value.


RE: IsNumeric validation Compact Framework 2.0 by davebythesea

davebythesea
Fri May 09 05:21:00 CDT 2008

Hi,

Maybe creating your own control which inherits from TextBox and only allows
to input a number value or digit?

Dav

"Malani Czornon" wrote:

> Hi, are there any function in C# to validate that the value from a textbox
> to be numeric ?
>
> Thanks in advance.
>
>
>

Re: IsNumeric validation Compact Framework 2.0 by Arun

Arun
Fri May 09 13:09:19 CDT 2008

May be something like this

class NumericTextBox : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (Char.IsDigit(e.KeyChar) ||
Char.IsControl(e.KeyChar) ||
(e.KeyChar =3D=3D '\b'))
{
// Digits/Control commands/backspace are OK
}
else
{
// Swallow this invalid key
e.Handled =3D true;
return;
}
}
}

or use setinputmode
http://msdn.microsoft.com/en-us/library/microsoft.windowsce.forms.inputmodee=
ditor.setinputmode.aspx

Hope this helps,
Cheers,
Arun



On May 9, 3:21=A0am, davebythesea
<davebythe...@discussions.microsoft.com> wrote:
> Hi,
>
> Maybe creating your own control which inherits from TextBox and only allow=
s
> to input a number value or digit?
>
> Dav
>
>
>
> "Malani Czornon" wrote:
> > Hi, are there any function in C# to validate that the value from a textb=
ox
> > to be numeric ?
>
> > Thanks in advance.- Hide quoted text -
>
> - Show quoted text -


Re: IsNumeric validation Compact Framework 2.0 by Arun

Arun
Fri May 09 13:14:09 CDT 2008

Better use word "Numeric TextBox" and do a google compact framework
group search
http://groups.google.com/advanced_group_search
you will get lots of threads discussed the same topic and few will
really help you.

Cheers,
Arun





On May 9, 11:09=A0am, Arun <arunkumarselva...@gmail.com> wrote:
> May be something like this
>
> class NumericTextBox : TextBox
> =A0 =A0 {
> =A0 =A0 =A0 =A0 protected override void OnKeyPress(KeyPressEventArgs e)
> =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 base.OnKeyPress(e);
> =A0 =A0 =A0 =A0 =A0 =A0 if (Char.IsDigit(e.KeyChar) ||
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Char.IsControl(e.KeyChar) ||
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (e.KeyChar =3D=3D '\b'))
> =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Digits/Control commands/backspace are O=
K
> =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 else
> =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Swallow this invalid key
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 e.Handled =3D true;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
> =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 }
> =A0 =A0 }
>
> or use setinputmodehttp://msdn.microsoft.com/en-us/library/microsoft.windo=
wsce.forms.inp...
>
> Hope this helps,
> Cheers,
> Arun
>
> On May 9, 3:21=A0am, davebythesea
>
>
>
> <davebythe...@discussions.microsoft.com> wrote:
> > Hi,
>
> > Maybe creating your own control which inherits from TextBox and only all=
ows
> > to input a number value or digit?
>
> > Dav
>
> > "Malani Czornon" wrote:
> > > Hi, are there any function in C# to validate that the value from a tex=
tbox
> > > to be numeric ?
>
> > > Thanks in advance.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


Re: IsNumeric validation Compact Framework 2.0 by Malani

Malani
Mon May 12 06:29:12 CDT 2008

Thanks a lot to all!!
I´ll search the best way to do it.

"Arun" <arunkumarselvaraj@gmail.com> escribió en el mensaje
news:86f610be-ab51-452f-ac63-db3eeaa4c778@w1g2000prd.googlegroups.com...
Better use word "Numeric TextBox" and do a google compact framework
group search
http://groups.google.com/advanced_group_search
you will get lots of threads discussed the same topic and few will
really help you.

Cheers,
Arun





On May 9, 11:09 am, Arun <arunkumarselva...@gmail.com> wrote:
> May be something like this
>
> class NumericTextBox : TextBox
> {
> protected override void OnKeyPress(KeyPressEventArgs e)
> {
> base.OnKeyPress(e);
> if (Char.IsDigit(e.KeyChar) ||
> Char.IsControl(e.KeyChar) ||
> (e.KeyChar == '\b'))
> {
> // Digits/Control commands/backspace are OK
> }
> else
> {
> // Swallow this invalid key
> e.Handled = true;
> return;
> }
> }
> }
>
> or use
> setinputmodehttp://msdn.microsoft.com/en-us/library/microsoft.windowsce.forms.inp...
>
> Hope this helps,
> Cheers,
> Arun
>
> On May 9, 3:21 am, davebythesea
>
>
>
> <davebythe...@discussions.microsoft.com> wrote:
> > Hi,
>
> > Maybe creating your own control which inherits from TextBox and only
> > allows
> > to input a number value or digit?
>
> > Dav
>
> > "Malani Czornon" wrote:
> > > Hi, are there any function in C# to validate that the value from a
> > > textbox
> > > to be numeric ?
>
> > > Thanks in advance.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -