Click here to Skip to main content
15,902,870 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am new in c#




how can i display error in messagebox if the textbox1 is a decimal number



thx all of you guy :)

What I have tried:

int A;
A = Convert.ToInt32(tbxTextBox1.Text);
if( A is a decimal number )
{messagebox.show("error");}
Posted
Updated 20-Oct-17 8:20am
Comments
Karthik_Mahalingam 20-Oct-17 22:59pm    
Show some example

1 solution

I assume when you mention decimal you mean a real number...

a.) Check whether Text conains a decimal seperator character
b.) In case there is a decimal separator: check whether at least one digit after (right of) decimal separator is not '0'
c.) In case there is a Digit != '0' after decimal separator it Looks like a decimal number, right? In case not it is an Natural number - Wikipedia[^]


Definition of Decimal[^]
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900