Click here to Skip to main content

glennPattonPUB asked:

Open original thread
Hi All,
 
Battling away I need to display a binary from a string "4020",
I have used the method
            MessageBox.Show(Returned);
            Hexvalue2 = Convert.ToUInt32(Returned, 16);
            MessageBox.Show(Hexvalue2.ToString());
to convert my string to a form that can be used that with
 
            if ((Hexvalue2 & 0x0001) == 0)
            {
                //MessageBox.Show("hello bit 1 not set");
                checkBox1.Checked = false;
                label9.Text = "False";
                }
            else
            {
               // MessageBox.Show("bit 1 set");
                checkBox1.Checked = true;
                label9.Text = "True"; 
            
            }
to check if bits are set and update a string accordingly This appears to working fine but bits 4 & 32 seem to inverted I was hoping for a look at the binary data before yelling fowl to higher ups! So I did the following
            Hexvalue2 = Convert.ToUInt32(IU_status,2);
            textBox2.Text = Hexvalue2.ToString();
and get an Could not find any recognizable digits error. Is the correct way of doing what I'm after or have I been seduced by Convert.To again?
 
Glenn
Tags: C#

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100