I'm trying to automatically convert a binary input in a textbox to a hex code in a second textbox.

It does work the way I'm trying to, but the order it comes out is wrong, for instance, 1111 = 0F this is correct, but when i now make it :
11111 i get 1F out of it what is of course wrong.

my code is:

private void textBox1_TextChanged(object sender, EventArgs e)
        {
            string hex;
            string hexwaarde;
            try
            {
                hex = textBox1.Text;
                hexwaarde = String.Format("{0:X2}", Convert.ToInt32(hex, 2));
                textBox2.Text = hexwaarde;
            }
            catch{}
        }

thanks in advance,
NdZ

just so you know....

11111 = 1F...
1111 = 0F...

so whats the problem then?

if you want the result to be F1 then your binary must be

11110001

lol srry made a mistake, haha thanks guys :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.