October 2nd, 2003, 09:49 AM
Convert char to string but got only the number
I want that 'Z' is shown in the textBox but I get 90! What must I change to get the letter not the number?
October 2nd, 2003, 11:13 AM
I don't understang really much what you want to do !
you have a CHAR and you want to add it in a text box ? then you should just do
textbox.text = b
or maybe if you want you could do a CSTR
like texbox.text = cstr(b) no ?
October 3rd, 2003, 06:51 AM
hang on a sec.
The only reason why you'd specify stuff as being strings or integers are such that the host program can use the appropriate resources and allocate sufficient overheads to accomplish whats its doing.
The fact you've got a number and assigned it to a numeric value, does not detract from the fact that if you convert it to string, you'll still just have a number.
Dim texttest as string
texttest = 1
will result in 1 being displayed, not an error message (even though it IS a number).
October 6th, 2003, 05:40 AM
I found a way:
October 7th, 2003, 10:22 AM
.NET does not automatically assume chars are strings, because .NET works with unicode.
The *proper* (nobody said easy) way to do it is to use the Encoding Classes in System.Text.Encoding to find the conversions.
char b = 'Z';
textBox1.Text = System.Text.Encoding.ASCII.GetString(b);