Results 1 to 13 of 13

Thread: Hex in a Format

  1. #1

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457

    Hex in a Format

    I do this

    VB Code:
    1. Result = Hex(10)

    my result would come out
    A

    but i want the result to come out in this format

    0x00000000

    so my awnser should be

    0x0000000A

    How can i do this I dont want my awnser to come over 8 Digits Long so there is always 8 after the X

    so say i did this

    VB Code:
    1. Result = Hex(something)

    Result would be.

    0x000000A1

    etc so it never goes over 8
    You Dig ?
    how can i do this ?
    www.azzmedia.co.uk

  2. #2
    AIS_DK
    Guest
    Havn't this been aswered already

    Please don't create multiple threads on the same question, but rather reply on the original, and thereby send it to the top of the thread list.

  3. #3

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    It was to Far back for me to Find and it wasnt awnsered because it didnt work
    so yet again can i please get help ?
    www.azzmedia.co.uk

  4. #4
    AIS_DK
    Guest
    Just to make one thing clear, this is based on one of the answer you got in your last thread, so if this works, then the person, who wrote the code, I base this on, should be credited.

    VB Code:
    1. Private Function ToHex(ByVal Number As Long) As String
    2. ToHex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Number)
    3. End Function

  5. #5

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    That Works in Part
    if its just 1 Digit to be added it puts it on the last one of the 8 which is good but if its 2 say it adds a digit onto the 8
    www.azzmedia.co.uk

  6. #6
    AIS_DK
    Guest
    What are you talking about?

    ToHex(0) = 0x00000000
    ToHex(1) = 0x00000001
    ToHex(10) = 0x0000000A
    Tohex(100) = 0x00000064
    ToHex(1000) = 0x000003E8

    I can't see, whats wrong here.

  7. #7

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    VB Code:
    1. Private Sub MakeHeader()
    2. Vertices = (txtFaces.Text * 4) 'Do Mathmatics
    3. Triangle = (txtFaces.Text * 2) 'Do Mathmatics
    4. UVValues = (Triangle * 3) 'Do Mathmatics
    5. Verticeshex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Vertices)
    6. Trianglehex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Triangle)
    7. UVValueshex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(UVValues)
    8. txtOutput.Text = "word    " & Verticeshex & "                                      ;num vertices"
    9. txtOutput.Text = txtOutput.Text & vbCrLf + "word    " & Verticeshex & "                                      ;num normals"
    10. txtOutput.Text = txtOutput.Text & vbCrLf + "word    " & UVValueshex & "                                      ;num UVs"
    11. txtOutput.Text = txtOutput.Text & vbCrLf + "word    0x00000000                                        ;num vertex colors"
    12. txtOutput.Text = txtOutput.Text & vbCrLf + "word    " & Trianglehex & "                                      ;num triangles"
    13. txtOutput.Text = txtOutput.Text & vbCrLf + "word    0x00000000                                        ;num BSP Nodes"
    14. txtOutput.Text = txtOutput.Text & vbCrLf + "word    0x00000000                                        ;num animation sequences"
    15. txtOutput.Text = txtOutput.Text & vbCrLf
    16. End Sub


    if I put in a Vaule that would just add 1 digit on end its fine

    word 0x00000004 ;num vertices
    word 0x00000004 ;num normals
    word 0x00000006 ;num UVs
    word 0x00000000 ;num vertex colors
    word 0x00000002 ;num triangles
    word 0x00000000 ;num BSP Nodes
    word 0x00000000 ;num animation sequences

    but if i Add 2 it just end up like this


    word 0x000000028 ;num vertices
    word 0x000000028 ;num normals
    word 0x00000003C ;num UVs
    word 0x00000000 ;num vertex colors
    word 0x000000014 ;num triangles
    word 0x00000000 ;num BSP Nodes
    word 0x00000000 ;num animation sequences
    www.azzmedia.co.uk

  8. #8

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    Well Im having no Luck can anyone shed some light on the situation ?
    www.azzmedia.co.uk

  9. #9
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350

    Bollocks

    Originally posted by Azz00
    It was to Far back for me to Find and it wasnt awnsered because it didnt work
    a) it was yesterday

    b) it worked, because I tested it.

    I was working on a response which only 1/2 worked and before posting 1/2 a reply I checked back and Lo! there was the solution.

    So if you think someone's solution doesn't work, well that's cool. Just continue the same thread with an explanation of why and let the thread flow.

    Or piss off.
    .

  10. #10

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    Ok Geez Im Sorry,
    they did anwser but it didnt work for me
    Im just looking for a bit of help thats all.
    www.azzmedia.co.uk

  11. #11
    AIS_DK
    Guest
    I don't think you have looked properly on the code you got, atleast you didn't implement it correctly.

    This
    VB Code:
    1. Verticeshex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Vertices)
    2. Trianglehex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Triangle)
    3. UVValueshex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(UVValues)
    Should be
    VB Code:
    1. Verticeshex = "0x" & String(8 - Len(Hex(Vertices)), "0") & Hex(Vertices)
    2. Trianglehex = "0x" & String(8 - Len(Hex(Trianglehex )), "0") & Hex(Triangle)
    3. UVValueshex = "0x" & String(8 - Len(Hex(UVValueshex)), "0") & Hex(UVValues)

  12. #12

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    lol thanks a lot
    it works thanks !
    www.azzmedia.co.uk

  13. #13
    AIS_DK
    Guest
    Your welcome!

    But you really should find the post from yesterday, and give the guy I based my code, some credit too.

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