Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Formatting Hexadecimal

mp3guymp3guy Posts: 24Member
I need to format a load of hexadecimal numbers. They go from 0 to FFFFFF. If I try to use

[code]Format(Text1.Text, "000000")[/code]

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

  • infidelinfidel Posts: 2,900Member
    [b][red]This message was edited by infidel at 2004-11-29 14:58:59[/red][/b][hr]
    : I need to format a load of hexadecimal numbers. They go from 0 to FFFFFF. If I try to use
    :
    : [code]Format(Text1.Text, "000000")[/code]
    :
    : 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.

    Something like this?

    [code]
    Private Sub Form_Load()

    MsgBox FormatHex("4A")
    MsgBox FormatHex("4104F")

    End Sub

    Private Function FormatHex(ByVal strValue As String) As String

    FormatHex = IIf(Len(strValue) Mod 2 = 0, strValue, "0" & strValue)

    End Function
    [/code]

    Or this?

    [code]
    Private Sub Form_Load()

    MsgBox FormatHex("4A")
    MsgBox FormatHex("4104F")

    End Sub

    Private Function FormatHex(ByVal strValue As String) As String

    FormatHex = Right("000000" & strValue, 6)

    End Function
    [/code]

    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]



Sign In or Register to comment.