|
-
Dec 1st, 2001, 06:57 AM
#1
Thread Starter
Hyperactive Member
Hex in a Format
I do this
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
Result would be.
0x000000A1
etc so it never goes over 8
You Dig ?
how can i do this ?
-
Dec 1st, 2001, 07:02 AM
#2
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.
-
Dec 1st, 2001, 07:19 AM
#3
Thread Starter
Hyperactive Member
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 ?
-
Dec 1st, 2001, 07:25 AM
#4
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:
Private Function ToHex(ByVal Number As Long) As String
ToHex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Number)
End Function
-
Dec 1st, 2001, 07:32 AM
#5
Thread Starter
Hyperactive Member
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
-
Dec 1st, 2001, 07:40 AM
#6
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.
-
Dec 1st, 2001, 07:53 AM
#7
Thread Starter
Hyperactive Member
VB Code:
Private Sub MakeHeader()
Vertices = (txtFaces.Text * 4) 'Do Mathmatics
Triangle = (txtFaces.Text * 2) 'Do Mathmatics
UVValues = (Triangle * 3) 'Do Mathmatics
Verticeshex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Vertices)
Trianglehex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Triangle)
UVValueshex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(UVValues)
txtOutput.Text = "word " & Verticeshex & " ;num vertices"
txtOutput.Text = txtOutput.Text & vbCrLf + "word " & Verticeshex & " ;num normals"
txtOutput.Text = txtOutput.Text & vbCrLf + "word " & UVValueshex & " ;num UVs"
txtOutput.Text = txtOutput.Text & vbCrLf + "word 0x00000000 ;num vertex colors"
txtOutput.Text = txtOutput.Text & vbCrLf + "word " & Trianglehex & " ;num triangles"
txtOutput.Text = txtOutput.Text & vbCrLf + "word 0x00000000 ;num BSP Nodes"
txtOutput.Text = txtOutput.Text & vbCrLf + "word 0x00000000 ;num animation sequences"
txtOutput.Text = txtOutput.Text & vbCrLf
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
-
Dec 1st, 2001, 08:17 AM
#8
Thread Starter
Hyperactive Member
Well Im having no Luck can anyone shed some light on the situation ?
-
Dec 1st, 2001, 08:26 AM
#9
Hyperactive Member
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.
-
Dec 1st, 2001, 08:32 AM
#10
Thread Starter
Hyperactive Member
Ok Geez Im Sorry,
they did anwser but it didnt work for me
Im just looking for a bit of help thats all.
-
Dec 1st, 2001, 09:04 AM
#11
I don't think you have looked properly on the code you got, atleast you didn't implement it correctly.
This
VB Code:
Verticeshex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Vertices)
Trianglehex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(Triangle)
UVValueshex = "0x" & String(8 - Len(Hex(Number)), "0") & Hex(UVValues)
Should be
VB Code:
Verticeshex = "0x" & String(8 - Len(Hex(Vertices)), "0") & Hex(Vertices)
Trianglehex = "0x" & String(8 - Len(Hex(Trianglehex )), "0") & Hex(Triangle)
UVValueshex = "0x" & String(8 - Len(Hex(UVValueshex)), "0") & Hex(UVValues)
-
Dec 1st, 2001, 09:25 AM
#12
Thread Starter
Hyperactive Member
lol thanks a lot
it works thanks !
-
Dec 1st, 2001, 09:33 AM
#13
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|