adsense


Saturday, 7 November 2015

VB SCRIPT NUMBER FORMATTING FUNCTIONS PAGE 31

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




VB SCRIPT NUMBER FORMATTING FUNCTIONS




Number Formatting Functions 


The Number formatting functions help the developers to express 
the given number in a format that they wish to. 

Description 


FormatNumber 	A Function, which would return an expression formatted as a number 
FormatPercent 	A Function, which would return an expression formatted as a percentage 

VBScript Number Formatting Functions Example 
Syntax 
variablename = Format_function_Name(Expression[,NumberDigAfterDec[,LeadingDig[, UseParForNegNum[,GroupDigits]]]])  

Description 

• The Required parameter Format_function_Name corresponds 
to any of the below listed number formatting functions. 

 

• The Optional parameter Expression corresponds to any 
numerical expression, which would result in a number. 

 

• The Optional parameter NumberDigAfterDec corresponds 
to the number of digits after the decimal place. 

 

• The Optional parameter LeadingDig corresponds to whether 
or not a leading zero is displayed for fractional values. 
It takes one of the three values based on the below settings parameter. 

 

• The Optional parameter UseParForNegNum corresponds to 
whether or not to place negative values within parentheses. 
It takes one of the three values based on the below settings parameter. 

 

• The Optional parameter GroupDigits corresponds to whether 
or not numbers are grouped using the group delimiter. 
It takes one of the three values based on the below settings parameter. 

Settings 
The above parameters LeadingDig, UseParForNegNum and 
GroupDigits arguments can have any of the following settings: 

• -2 = vbUseDefault - Use the computer's regional settings 

 

• -1 = vbTrue - True 

 

• 0 = vbFalse - False 

Example 
Try the following example to understand all the Number 
Formatting Functions available in VBScript. 

<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 
Dim num : num = -645.998651 
 
document.write("Line 1 : " & FormatNumber(num, 3))& "<br/>" 
 
' The UseParensForNegativeNumbers parameter is set to true. 
document.write("Line 2 : " & FormatNumber (num, 3, , vbTrue))&" <br/> " 
 
' The GroupDigits parameter is set to false. 
document.write("Line 3 : " & FormatNumber (num, 3, , , vbFalse)) & "<br/>" 
 
document.write("Line 4 : " & FormatPercent(num, 3))& "<br/>" 
 
' The UseParensForNegativeNumbers parameter is set to true. 
document.write("Line 5 : " & FormatPercent (num, 3, , vbTrue))&" <br/> " 
 
' The GroupDigits parameter is set to false. 
document.write("Line 6 : " & FormatPercent (num, 3, , , vbFalse)) & "<br/>" 
 
</script> 
</body> 
</html> 
When executed, the above script will produce the following output: 
Line 1 : -645.999 
Line 2 : (645.999)  
Line 3 : -645.999 
Line 4 : -64,599.865% 
Line 5 : (64,599.865%)  
Line 6 : -64599.865% 



No comments: