How To Use CLng() to Convert Hexadecimal Number back to Decimal in VBScript (279115)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1
  • Microsoft Internet Explorer (Programming) 4.01 SP2
  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 5.01
  • Microsoft Internet Explorer (Programming) 5.01 SP1
  • Microsoft Internet Explorer (Programming) 5.5

This article was previously published under Q279115

SUMMARY

In Microsoft Visual Basic Scripting Edition (VBScript), you can use the Hex function to convert a decimal to a hexadecimal number. This article contains sample code that converts 32-bit signed hexadecimal values back to decimal.

MORE INFORMATION

To convert a decimal to a hexadecimal number, use the VBScript Hex function. To convert a hexadecimal number to a decimal, use the VBScript data type conversion functions, CInt and CLng, as follows:
<HTML>
<BODY>

<SCRIPT LANGUAGE="VBScript">

Sub Hex_to_Dec(hex_value)

	MsgBox CLng("&h" & hex_value)

End Sub

</SCRIPT>
Convert Hex to Decimal:<BR>
<INPUT TYPE="text" ID="text1" NAME="text1" maxlength=8 size=8>
<INPUT TYPE="button" value="Button" ID="button1" NAME="button1" onclick="hex_to_dec(text1.value)">

</BODY>
</HTML>
				

REFERENCES

For more information on the Hex function, see the following Microsoft Developer Network (MSDN) Web site: For more information on the CLng function, see the following MSDN Web site: For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

Modification Type:MajorLast Reviewed:5/11/2006
Keywords:kbhowto kbScript KB279115