Jump to content
Tuts 4 You

Vb - Hex2dec


Guest Dater_

Recommended Posts

Guest Dater_
Posted

Hi.

I have problem with converting Hex to Dec in VB.

I have hex string for example "975D46ED" - in HexDecChar by Ap0x it is "-1755494675" (bad) but in CrackersTool it is "2539472621"(good). Hmm strange...

My code is :

SerialHex = CStr(Blabla1hex) & CStr(Blabla2hex) & CStr(Blabla3hex) Hex2Dec = CLng("&H" + SerialHex)Text2.Text = Hex2Dec

And my app give me...bad "-1755494675" not good "2539472621".

Can anyone help ?

Posted
Hi.

I have problem with converting Hex to Dec in VB.

I have hex string for example "975D46ED" - in HexDecChar by Ap0x it is "-1755494675" (bad) but in CrackersTool it is "2539472621"(good). Hmm strange...

My code is :

SerialHex = CStr(Blabla1hex) & CStr(Blabla2hex) & CStr(Blabla3hex) Hex2Dec = CLng("&H" + SerialHex)Text2.Text = Hex2Dec

And my app give me...bad "-1755494675" not good "2539472621".

Can anyone help ?

I have no idea about vb coding ,but you are getting the result as signed #, just get the output as unsigned # , you will have the desired result. Regards.

Posted (edited)

Dater,

Try the following:

Function LongToUnsigned(Value As Long) As Double
If Value < 0 Then
LongToUnsigned = Value + 4294967296#
Else
LongToUnsigned = Value
End If
End Function'Use the function like this in your code
Text2.Text = LongToUnsigned(Hex2Dec)

Code Source: http://support.microsoft.com/kb/q189323/

Happy Coding,

Napalm

Edited by Napalm
Guest Dater_
Posted

Thanks guys.

Napalm this is my working code:

EndString = CStr(Looop4bHex) & CStr(Looop4cHex) & CStr(Looop4dHex) & CStr(EndAlgoHex)Hex2Dec = CLng("&H" + EndString)Text2.Text = LongToUnsigned(Hex2Dec)End SubFunction LongToUnsigned(Value As Long) As Double
If Value < 0 Then
LongToUnsigned = Value + 4294967296#
Else
LongToUnsigned = Value
End If
End Function

This converts "975D46ED" to "2539472621" and from other 5lenght names too...But not for all for example for "david" returns me "Runtime error '6': Overflow" ;)

So my next question is - it is depend to "4294967296#" from code ?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...