Results 1 to 3 of 3

Thread: [RESOLVED] Formatting a hexadecimal number.

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    41

    Resolved [RESOLVED] Formatting a hexadecimal number.

    I'm trying to force a four digit display of a hexadecimal number using:
    Code:
    something.text=format$(Hex(number),"0000")
    This works if the resulting hex number is numeric, but for alphanumeric numbers it works strange. e.g.

    4A yields 0000 <--- This is puzzling. Why only the "A" numbers?
    4B yields 4B
    4C yields 4C
    ...
    4F yields 4F

    I could pad with leading zeros, but maybe someone knows an easier way.

    Thanks
    Jon

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Formatting a hexadecimal number.

    something.Text = Right$("000" & Hex(number), 4)

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    41

    Re: Formatting a hexadecimal number.

    Thanks Joacim, that did the trick.

    Jon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width