Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Dear...

 

I need to convert a hexadecimal code (string of 1 byte) to a binary code (string of 4 bytes).

Other possible solutions are okay too.

 

The help-file gives the following solution:

 

 

Code:

--------------------------------------------------------------------------------

�Function HexToBinary( ByVal HexString As String) As String�

 

 

--------------------------------------------------------------------------------

 

 

 

Does anyone know how to do this ?

 

Regards,

BuddyB

  • Leaders
Posted

One solution would probably be to call a few replace methods.

Replace 0 with 0000, 1 with 0001, 2 with 0010, 3 with 0011, etc.

E with 1110, and F with 1111. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

  • *Experts*
Posted

Try this:

// s is the hex string
string s = "C2";
// b will be the binary string
string b = Convert.ToString(Convert.ToInt32(s, 16), 2);

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...