Textbox C#
-
How can I set a textbox value to a number....I tried the ToString method but im not sure
OlieColie wrote:
How can I set a textbox value to a number....I tried the ToString method but im not sure
What do you mean you are not sure? You are not sure that will work? You are not sure it is the best way? Have you tried it? Did it work?
MyTextBox.Text = myNumber.ToString();
There isn't much more to it than that.
Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website
-
How can I set a textbox value to a number....I tried the ToString method but im not sure
OlieColie wrote:
How can I set a textbox value to a number....I tried the ToString method but im not sure
Your question doesn't make any sense. Do you want to case text box value to a number ? Then check the following code
int MyNumber = (int)Text1.Text;
int MyNumber = int.Parse(Text1.Text);
int MyNumber = Convert.ToInt32(Text1.Text);These are different methods for casting