Newbie help with chars and ASCII!

I am using Visual Studio using c++ in a Windows Form application.

I have a char which holds a value. I need to add the value to a text box, so I have:

char x;
textBox2->Text = x.ToString();

Trouble is I need to get the ASCII value instead of the decimal.

i.e. if x has 117 in it I want to get 'u' in the string, at the moment I get 117.

Any easy way to do this!

Really appreciate any help!
characters are integers. If you can get the numerical 117, that is the character 'u'. All you have to do is cast it:

1
2
3
4
int v = 117;
char c = (char)x;

if( c == 'u' )  // <- this will be true 



EDIT: Actually I don't know if this answers your question. =x
Last edited on
Thanks for the response. The problem with that though was I would still get 117 when I append the value on a text box. Got it to work now by:

textBox2->AppendText(gcnew String(x, 1));
Topic archived. No new replies allowed.