Guest Dater_ Posted July 26, 2006 Posted July 26, 2006 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 = Hex2DecAnd my app give me...bad "-1755494675" not good "2539472621".Can anyone help ?
britedream Posted July 26, 2006 Posted July 26, 2006 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 = Hex2DecAnd 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.
Napalm Posted July 26, 2006 Posted July 26, 2006 (edited) Dater,Try the following:Function LongToUnsigned(Value As Long) As Double If Value < 0 Then LongToUnsigned = Value + 4294967296# Else LongToUnsigned = Value End IfEnd Function'Use the function like this in your codeText2.Text = LongToUnsigned(Hex2Dec)Code Source: http://support.microsoft.com/kb/q189323/Happy Coding,Napalm Edited July 26, 2006 by Napalm
Guest Dater_ Posted July 27, 2006 Posted July 27, 2006 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 IfEnd 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 ?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now