adsense


Saturday, 7 November 2015

VB SCRIPT NUMBER CONVERSION FUNCTION PAGE 30

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button




VB SCRIPT NUMBER CONVERSION FUNCTION




Number Conversion Functions 

Number functions help us to convert a given number from one data subtype to another data subtype. 



Function 	Description 
CDbl 	A Function, which converts a given number of any variant subtype to double 
CInt 	A Function, which converts a given number of any variant subtype to Integer 
CLng 	A Function, which converts a given number of any variant subtype to Long 
CSng 	A Function, which converts a given number of any variant subtype to Single 
Hex 	A Function, which converts a given number of any variant subtype to Hexadecimal 
VBScript Number Conversion Functions Example 
Syntax 
Variable_name = Conversion_function_name(expression) 
Example 
Try the following example to understand all the Number 
Conversion Functions available in VBScript. 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
x = 123 
y = 123.882 
 
document.write("x value after converting to double - " & CDbl(x) & "<br />") 
document.write("y value after converting to double - " & CDbl(y) & "<br />") 
document.write("x value after converting to Int -" & CInt(x) & "<br />") 
document.write("y value after converting to Int -" & CInt(y) & "<br />") 
document.write("x value after converting to Long -" & CLng(x) & "<br />") 
document.write("y value after converting to Long -" & CLng(y) & "<br />")  
document.write("x value after converting to Single -" & CSng(x) & "<br />") 
document.write("y value after converting to Single -" & CSng(y) & "<br />")  
document.write("x value after converting to Hex -" & Hex(x) & "<br />") 
document.write("y value after converting to Hex -" & Hex(y) & "<br />")  
</script> 
</body> 
</html> 

When executed, the above script will produce the following output: 
x value after converting to double - 123 
y value after converting to double - 123.882 
x value after converting to Int -123 
y value after converting to Int -124 
x value after converting to Long -123 
y value after converting to Long -124 
x value after converting to Single -123 
y value after converting to Single -123.882 
x value after converting to Hex -7B 
y value after converting to Hex -7C 




No comments: