PDA

View Full Version : Using MSXML2.ixtlruntime functions in JavaScript


deadstone
10-16-2003, 11:15 AM
Hi all,

In JavaScript or VB I want to use the XML - IXTLRuntime method FormatNumber. Trouble is that the class is Not Creatable, though it is Public (in VB Object Browser!).

In the documentation (XML 3) it even states there is a Visual Basic syntax like this:

strValue = oXTLRuntime.formatNumber(dblNumber, bstrFormat)

so I tried this code:
>>>> CODE SNIPPET >>>>
Dim xmlFunc As MSXML2.IXTLRuntime
Dim xyz As Double
Dim abc As String

xyz = 1234567.89
set xmlfunc=new msxml.ixtlruntime ' DOES NOT WORK !!!
abc = xmlFunc.FormatNumber(xyz, ",")

<<<< END CODE <<<<

and it does not work. This, of course is because the class is not createable.

So what interface can I use to access this function in VB or JavaScript without using an XSL STylesheet!

The reason is not to use it in VB of course, but in fact to use it in JavaScript on a client using the New ActiveX Object syntax. Then I can format a number to currency in 1 line of code!

thanks for any help

Philip

LeXRus
10-18-2003, 07:34 PM
in MSXML API History: "IXTLRuntime (not implemented in MSXML 4.0)"

you can make javascript to do it

<script>
function formatNumber(num,spl){
return num.toString().split('').reverse().join('').replace(/(?=\d*\.?)(\d{3})/img,'$1,').split('').reverse().join('');
}

alert(formatNumber(1234567.89));
</script>


or using the format-number function of xslt if you want~

deadstone
10-21-2003, 10:04 AM
thanks for that