If all the inputs entered into the text box is numeric values so it is quite easy to transform string into integer*(Note that TextBox value is always taken as string no matter what value is givien to it)*. The problem I am facing is that I am taking string or Char value as input in a TextBox and want to transform that value into en integer.
I have searched and compiled many ways to do that such as follows,
Just for the sake of example, we assume that TextBox1 holds "A" as input.
int hold = Convert::ToInt32(TextBox1->Text)
or
String^ str = TextBox1->Text;
int hold = Convert::ToInt32(TextBox1->Text)
or
int hold = Convert::ToInt32(tbx1->Text->ToString());
or
String^ str = TextBox1->Text;
int hold = int::Parse(str);
What could be the possible way to get it done. The error I am getting is System.FormatException occurred in mscorlib.dl.
Thanks in advanced.
Aucun commentaire:
Enregistrer un commentaire