Click here to Skip to main content
15,888,082 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can you please tell me how to check whether the numbers are presented in the textbox or not?
thanks,
Posted
Comments
darkDercane 5-Jan-12 10:05am    
maybe u can check if the textbox is fill or not, and maybe u can do a simple regex to check if is a number or not :P

You can also use Contains property which is used to returns a value indicating whether the specified String object
bool res =textBox1.Text.Contains("your Value"); // res will contain true if values is present 
 
Share this answer
 
v2
Is this what you are looking for

C#
//assuming a textbox named textbox1

int anInteger;
anInteger = Convert.ToInt32(textBox1.Text);//get the text as an integer

//or 
anInteger = int.Parse(textBox1.Text); //try to parse the value as an integer

another method is possibly
var match = textBox1.Text.IndexOfAny("1234567890".ToCharArray()) != -1
 
Share this answer
 

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