Click to See Complete Forum and Search --> : Convert string to char


beanimanius
August 7th, 2004, 10:56 AM
How would I go about taking a textbox input (String) and converting that to a char, manipulating the char, and then displaying the result in a label?

I can't find an example of this, and I have been staring at the MSDN for the last couple hours with no luck. I need a push in the right direction.

beanimanius
August 7th, 2004, 03:43 PM
I just figured it out but I need some help with the exception for there is a
better way to do it.

This is when the text changes in textinput.

System::Int16 input, sub, result;

try {
input = Convert::ToInt16(textInput->Text);
sub = input - 10;
result = sub/2;
labelResult->Text = result.ToString();
}
catch(System::FormatException *fmtE)
{
MessageBox::Show(fmtE->Message);
}

I would like it if it didn't freak out when the textbox is empty (ie. when
the user decides to put in a different number) and for the label to be empty
when the textbox is empty.