Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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>
				

↑ Back to the top


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:

↑ Back to the top


Properties

Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

↑ Back to the top


Keywords: KB279115, kbscript, kbhowto

↑ Back to the top

Article Info
Article ID : 279115
Revision : 4
Created on : 8/8/2007
Published on : 8/8/2007
Exists online : False
Views : 358