473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,399 developers and data experts.

Display a byte as two hex digits

8,435 Expert 8TB
Using Hex$() you can easily convert a byte (or larger value) to a hex representation. However, it comes out as one or two bytes, which can mess up your text alignment. This simple function provides a consistent two-digit hex string.
Expand|Select|Wrap|Line Numbers
  1. Public Function HexByte2Char(ByVal Value As Byte) As String
  2.   ' Return a byte value as a two-digit hex string.
  3.   HexByte2Char = IIf(Value < &H10, "0", "") & Hex$(Value)
  4. End Function
Jul 11 '07 #1
3 23308
Using Hex$() you can easily convert a byte (or larger value) to a hex representation. However, it comes out as one or two bytes, which can mess up your text alignment. This simple function provides a consistent two-digit hex string.
Expand|Select|Wrap|Line Numbers
  1. Public Function HexByte2Char(ByVal Value As Byte) As String
  2.   ' Return a byte value as a two-digit hex string.
  3.   HexByte2Char = IIf(Value < &H10, "0", "") & Hex$(Value)
  4. End Function
How do you convert hex2byte?
Sep 14 '07 #2
Killer42
8,435 Expert 8TB
How do you convert hex2byte?
Can you explain what you mean? If you just want to convert a hex string to a byte value, try something like Val("&h" & <your-value>).



In future, please don't ask questions here in the Articles area. They should go in the main forum.
Sep 15 '07 #3
JosAH
11,448 Expert 8TB
Can you explain what you mean? If you just want to convert a hex string to a byte value, try something like Val("&h" & <your-value>).



In future, please don't ask questions here in the Articles area. They should go in the main forum.
This is exactly the reason I'd prefer articles in this section to be closed.

kind regards,

Jos
Sep 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: pembed2003 | last post by:
"news.hku.hk" <billychu@hkusua.hku.hk> wrote in message news:<408e8476$2@newsgate.hku.hk>... > thanks for all of your's help > but i still can't grasp the idea of the algorithm > maybe could...
47
by: Kapil Khosla | last post by:
Hi, I am trying to reverse a byte eg. 11010000 should look like 00001011 Plz note, it is not a homework problem and I do not need the c code for it. Just give me an idea how should I proceed...
40
by: aku | last post by:
I'm looking for the absolute fastest way to count the nr of bits that are set to "1" in a string. Presumably I then first need the fastest way to do this in a byte. I think this is it, but...
9
by: sudi | last post by:
HI, I face the task of converting a 6 byte integer (MSB first) to a decimal string. The platform I use supports only 4 byte basic data type. I have written some algorithms that loops to many...
4
by: Ping | last post by:
Hi, All, We can use BitConverter.ToString(byte) to a string, but how to get the byte from a string like "AD-A6-0D-1F"?
4
by: msosno01 | last post by:
I have Java client that connects to C++ server. The client sends integer in binary using DataOutputStream write function. I am reading these data into buffer. I have to convert this buffer back...
11
by: vila | last post by:
Hi, I would like to display digits with a 7-bar display, as in a pocket calculator. Any ideas about how to do this? Francis
16
by: Hugh Janus | last post by:
Hi all, I am using the below functions in order to convert strings to bytes and vice versa. I totally ans shamefully stole these functions from this group btw! Anyway, they work great but as...
2
by: djones | last post by:
I have a byte array that contains a string like 1c1ba2... etc I would like to print out 5 digits. so for example: 1c = 28 1b = 27 a2 = 162 my output needs to be five digits long so 28271. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.