Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Formatting Hex in VB6

  • 28-11-2004 12:15PM
    #1
    Registered Users, Registered Users 2 Posts: 3,946 ✭✭✭


    I need to format a load of hexadecimal numbers. They go from 0 to FFFFFF. If I try to use

    Format(Text1.Text, "000000")

    saying text1.text contains 4104F, it returns 4104F. I need it to return 04104F. Is there any way to do it? And the hex length is varying, could be 2 characters, like 4A or 6 chars like 564A89.


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    I've had similiar problems with the Format function in the past. I wrote my own little format function and used that instead. You need to loop determine how many preceeding zeros you need and then add them to the string which represents your hex value.


  • Registered Users, Registered Users 2 Posts: 3,946 ✭✭✭mp3guy


    could you give me a little help with that? I've no idea how to say "If there 1 char, add 5 "0"'s, if theres 2 chars add 4 "0"'s etc..." In visual basic


Advertisement