interviews.dotnetthread.com

↑ Grab this Headline Animator

Sunday, May 24, 2009

Rounding a number after decimal point using Vb script Format functions

Below is the function in the vbscript which will round the number up to two digits after decimal number.



<Script language="VBScript">

Function Roundnumber(Decnumber,numlength)

Roundnumber = FormatCurrency(Decnumber,numlength,,,0)

Roundnumber = FormatNumber(Decnumber,numlength,,,0)

End Function

</Script>

<Script language="JavaScript">

function roundnumjavascript(number,length)

{

document.getElementById('textBox1').value= Roundnumber(number,length)

}

</Script>

In HTML

<input type="text" id="textBox1"/>

<input type="button" id="btnround" value="Roundnum" onclick="roundnumjavascript(document.getElementById('textBox1').value,2);"/>

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles