0

I get binary data from a file which is to be displayed in hex byte wise(i.e. 2 digits).
format$(hex(num),"00") places a leading zero for single digit numbers but it doesnot support for hex (A-F). How do i get leading zeroes for bytes of values A-F?
Is there any simplae way like format function rather compare and then pad '0' using left$?


regards,
Prathima

2
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by pbosek
0

I tried

temp = IIf((Hex(Status) >= Hex(10) And Hex(Status) <= Hex(15)), "0" & Hex(Status), Hex(Status))
  ToFile = ToFile & Format$(temp, "00") & " "

But seems it works as string compare after conversion to hex.
For values like "C8" it returns "0C8". It returns evry value with A-F with a leading zero.
help pls,

Edited by mike_2000_17: Fixed formatting

0

Yes, finally i could make it. i compared it in decimal and then converted to hex

temp = IIf((num >= 10 And num <= 15), "0" & Hex(num), Hex(num))
        ToFile = ToFile & Format$(temp, "00")

let me know if you have any alternative

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.