Function 希望asp classic中的“14120000”输出为“1412万”

Function 希望asp classic中的“14120000”输出为“1412万”,function,asp-classic,Function,Asp Classic,我的代码是asp经典。我不会走错方向。你们能帮帮我吗 <% response.write("Hi") response.end() function nicenumber(n) n = (replace(",","",n)) if(!IsNumeric(n)) then nicenumber = false end if if(n>1000000000000) then

我的代码是asp经典。我不会走错方向。你们能帮帮我吗

    <%
response.write("Hi")
response.end()
    function nicenumber(n) 
        n = (replace(",","",n))

        if(!IsNumeric(n)) then
        nicenumber = false
        end if
        if(n>1000000000000) then 
        nicenumber = round((n/1000000000000),2) & " trillion"
        else if(n>1000000000) then 
        nicenumber = round((n/1000000000),2) & " billion"
        else if(n>1000000) then
        nicenumber = round((n/1000000),2) & " million"
        else if(n>1000) then
        nicenumber = round((n/1000),2) & " thousand"
        end if
        nicenumber = number_format(n)

    End function

response.write(nicenumber("14120000")) '14.12 million

%>
输入:-14120000 所需产量:-1412万
希望asp classic中的“14120000”输出为“1412万”

我已经向您的问题解释了您的大部分错误;其余的。这是代码。享受

<%
function NiceNumber(n) 
        n = replace(n, ",","")

        if(not IsNumeric(n)) then
            NiceNumber = false
        elseif (n>=1e12) then 
            NiceNumber = FormatNumber((n/1e12),2) & " trillion"
        elseif(n>=1e9) then 
            NiceNumber = FormatNumber((n/1e9),2) & " billion"
        elseif(n>=1e6) then
            NiceNumber = FormatNumber((n/1e6),2) & " million"
        elseif(n>=1e3) then
            NiceNumber = FormatNumber((n/1e3),2) & " thousand"
        else
            NiceNumber = FormatNumber(n)
        end if
End function

SetLocale(1033) 'EN-US  (1043 = NL-NL for example)
x = "1234567890123456789"
For i = 1 to len(x)
    response.write(Left(x, i) & " &raquo; " & NiceNumber(Left(x, i))) & "<br>"
Next
%>

查找更多格式选项。

您有什么问题?这应该是jscript还是vbscript?经典的ASP可以使用任何一种。因为vbscript不使用return;您应该使用nice_number=foo而不是return foo。看见除此之外:你应该清楚地说明你的问题。您预期会发生什么,实际会发生什么等等@RobIII无论语言是VBscript还是Javascript,函数中都有一系列错误。Javascript不包含所列的圆形或非数字函数,它还缺少行终止符。如果是vbscript,则函数语法错误vbscript不使用大括号。正如您所指出的,return命令也是asp经典。请向我推荐任何其他选项asp classic:asp classic没有说明您使用的是VBScript还是JScript;两者都是ASP classic中的选项。请告诉我其他的选择:还有什么选择?您需要编写正确的代码。。。您的问题最初包含JScript和VBScript的混合体,因此不起作用。然后,你对你的问题进行了太多的编辑,以至于现在的评论毫无意义。再次:告诉我们发生了什么,你会犯什么错误,等等。这里有一个提示:!VBScript中没有运算符,只有JScript。您需要将not用于VBScript。你还漏掉了一个结束if。你需要重新考虑一下你在开始时转换n的方式。如果n还不是数字,您将得到一个错误。以所有仍然喜欢经典asp的开发人员的名义感谢您:
<%@ language="vbscript" %>
<%



Set cd = CreateObject("ChartDirector.API")


'Data for the chart as 3 random data series

'response.Write("Hi")
Set r = cd.RanSeries(127)
response.Write("HI")
data0 = r.getSeries(100, 100, -15, 15)
data1 = r.getSeries(100, 150, -15, 15)
data2 = r.getSeries(100, 200, -15, 15)

timeStamps = r.getDateSeries(100, DateSerial(2011, 1, 1), 86400)

' Create a XYChart object of size 640 x 400 pixels
Set c = cd.XYChart(640, 400)

' Add a title to the chart using 18 pts Times New Roman Bold Italic font
Call c.addTitle("Product Line Global Revenue", "timesbi.ttf", 18)

' Set the plotarea at (50, 55) with width 70 pixels less than chart width, and height 90 pixels less
' than chart height. Use a vertical gradient from light blue (f0f6ff) to sky blue (a0c0ff) as
' background. Set border to transparent and grid lines to white (ffffff).
Call c.setPlotArea(50, 55, c.getWidth() - 70, c.getHeight() - 90, c.linearGradientColor(0, 55, 0, _
     c.getHeight() - 35, &Hf0f6ff, &Ha0c0ff), -1, cd.Transparent, &Hffffff, &Hffffff)

' Add a legend box at (50, 25) using horizontal layout. Use 10pts Arial Bold as font. Set the
' background and border color to Transparent.
Call c.addLegend(50, 25, False, "arialbd.ttf", 10).setBackground(cd.Transparent)

' Set axis label style to 8pts Arial Bold
Call c.xAxis().setLabelStyle("arialbd.ttf", 8)
Call c.yAxis().setLabelStyle("arialbd.ttf", 8)

' Set the axis stem to transparent
Call c.xAxis().setColors(cd.Transparent)
Call c.yAxis().setColors(cd.Transparent)

' Configure x-axis label format
Call c.xAxis().setMultiFormat(cd.StartOfYearFilter(), "{value|mm/yyyy} ", cd.StartOfMonthFilter(), _
    "{value|mm}")

' Add axis title using 10pts Arial Bold Italic font
Call c.yAxis().setTitle("USD millions", "arialbi.ttf", 10)

' Add a line layer to the chart using a line width of 2 pixels.
Set layer = c.addLineLayer2()
Call layer.setLineWidth(2)

' Add 3 data series to the line layer
Call layer.setXData(timeStamps)
Call layer.addDataSet(data0, &Hff3333, "Alpha")
Call layer.addDataSet(data1, &H008800, "Beta")
Call layer.addDataSet(data2, &H3333cc, "Gamma")

' Create the WebChartViewer object
Set viewer = cd.WebChartViewer(Request, "chart1")

' Output the chart
chartQuery = c.makeSession(Session, viewer.Id)

' Set the chart URL to the viewer
viewer.ImageUrl = "getchart.asp?" & chartQuery

' Output Javascript chart model to the browser to support tracking cursor
viewer.ChartModel = c.getJsChartModel()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Track Line with Data Labels</title>
    <script type="text/javascript" src="cdjcv.js"></script>
</head>
<body style="margin:5px 0px 0px 5px">
<script type="text/javascript">

//
// Use the window load event to set up the MouseMovePlotArea event handler
//
JsChartViewer.addEventListener(window, 'load', function() {
    var viewer = JsChartViewer.get('<%=viewer.Id%>');

    // Draw track cursor when mouse is moving over plotarea. Hide it when mouse leaves plot area.
    viewer.attachHandler("MouseMovePlotArea", function(e) {
        trackLineLabel(viewer, viewer.getPlotAreaMouseX());
        viewer.setAutoHide("all", "MouseOutPlotArea");
    });
});

//
// Draw track line with data labels
//
function trackLineLabel(viewer, mouseX)
{
    // Remove all previously drawn tracking object
    viewer.hideObj("all");

    // The chart and its plot area
    var c = viewer.getChart();
    var plotArea = c.getPlotArea();

    // Get the data x-value that is nearest to the mouse, and find its pixel coordinate.
    var xValue = c.getNearestXValue(mouseX);
    var xCoor = c.getXCoor(xValue);

    // Draw a vertical track line at the x-position
    viewer.drawVLine("trackLine", xCoor, plotArea.getTopY(), plotArea.getBottomY(), "black 1px dotted");

    // Draw a label on the x-axis to show the track line position
    viewer.showTextBox("xAxisLabel", xCoor, plotArea.getBottomY() + 4, JsChartViewer.Top,
        c.xAxis().getFormattedLabel(xValue, "mmm dd, yyyy"),
        "font:bold 11px Arial;color:#FFFFFF;background-color:#000000;padding:0px 3px");

    // Iterate through all layers to draw the data labels
    for (var i = 0; i < c.getLayerCount(); ++i)
    {
        var layer = c.getLayerByZ(i);

        // The data array index of the x-value
        var xIndex = layer.getXIndexOf(xValue);

        // Iterate through all the data sets in the layer
        for (var j = 0; j < layer.getDataSetCount(); ++j)
        {
            var dataSet = layer.getDataSetByZ(j);

            // Get the color and position of the data label
            var color = dataSet.getDataColor();
            var yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis());

            // Draw a track dot with a label next to it for visible data points in the plot area
            if ((yCoor != null) && (yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY()) &&
                (color != null))
            {
                viewer.showTextBox("dataPoint" + i + "_" + j, xCoor, yCoor, JsChartViewer.Center,
                    viewer.htmlRect(7, 7, color));

                viewer.showTextBox("dataLabel" + i + "_" + j, xCoor + 5, yCoor, JsChartViewer.Left,
                    dataSet.getValue(xIndex).toPrecision(4),
                    "padding:0px 3px;font:bold 10px Arial;background-color:" + color + ";color:#FFFFFF");
            }
        }
    }
}

</script>
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
    Track Line with Data Labels
</div>
<hr style="border:solid 1px #000080" />
<div style="font-size:10pt; font-family:verdana; margin-bottom:1.5em">
    <a href="viewsource.asp?file=<%=Request("SCRIPT_NAME")%>">View Source Code</a>
</div>
<!-- ****** Here is the chart image ****** -->
<%=viewer.renderHTML()%>

</body>
</html>
<%@ language="vbscript" %>
<%



Set cd = CreateObject("ChartDirector.API")


'Data for the chart as 3 random data series

'response.Write("Hi")
Set r = cd.RanSeries(127)
response.Write("HI")
data0 = r.getSeries(100, 100, -15, 15)
data1 = r.getSeries(100, 150, -15, 15)
data2 = r.getSeries(100, 200, -15, 15)

timeStamps = r.getDateSeries(100, DateSerial(2011, 1, 1), 86400)

' Create a XYChart object of size 640 x 400 pixels
Set c = cd.XYChart(640, 400)

' Add a title to the chart using 18 pts Times New Roman Bold Italic font
Call c.addTitle("Product Line Global Revenue", "timesbi.ttf", 18)

' Set the plotarea at (50, 55) with width 70 pixels less than chart width, and height 90 pixels less
' than chart height. Use a vertical gradient from light blue (f0f6ff) to sky blue (a0c0ff) as
' background. Set border to transparent and grid lines to white (ffffff).
Call c.setPlotArea(50, 55, c.getWidth() - 70, c.getHeight() - 90, c.linearGradientColor(0, 55, 0, _
     c.getHeight() - 35, &Hf0f6ff, &Ha0c0ff), -1, cd.Transparent, &Hffffff, &Hffffff)

' Add a legend box at (50, 25) using horizontal layout. Use 10pts Arial Bold as font. Set the
' background and border color to Transparent.
Call c.addLegend(50, 25, False, "arialbd.ttf", 10).setBackground(cd.Transparent)

' Set axis label style to 8pts Arial Bold
Call c.xAxis().setLabelStyle("arialbd.ttf", 8)
Call c.yAxis().setLabelStyle("arialbd.ttf", 8)

' Set the axis stem to transparent
Call c.xAxis().setColors(cd.Transparent)
Call c.yAxis().setColors(cd.Transparent)

' Configure x-axis label format
Call c.xAxis().setMultiFormat(cd.StartOfYearFilter(), "{value|mm/yyyy} ", cd.StartOfMonthFilter(), _
    "{value|mm}")

' Add axis title using 10pts Arial Bold Italic font
Call c.yAxis().setTitle("USD millions", "arialbi.ttf", 10)

' Add a line layer to the chart using a line width of 2 pixels.
Set layer = c.addLineLayer2()
Call layer.setLineWidth(2)

' Add 3 data series to the line layer
Call layer.setXData(timeStamps)
Call layer.addDataSet(data0, &Hff3333, "Alpha")
Call layer.addDataSet(data1, &H008800, "Beta")
Call layer.addDataSet(data2, &H3333cc, "Gamma")

' Create the WebChartViewer object
Set viewer = cd.WebChartViewer(Request, "chart1")

' Output the chart
chartQuery = c.makeSession(Session, viewer.Id)

' Set the chart URL to the viewer
viewer.ImageUrl = "getchart.asp?" & chartQuery

' Output Javascript chart model to the browser to support tracking cursor
viewer.ChartModel = c.getJsChartModel()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Track Line with Data Labels</title>
    <script type="text/javascript" src="cdjcv.js"></script>
</head>
<body style="margin:5px 0px 0px 5px">
<script type="text/javascript">

//
// Use the window load event to set up the MouseMovePlotArea event handler
//
JsChartViewer.addEventListener(window, 'load', function() {
    var viewer = JsChartViewer.get('<%=viewer.Id%>');

    // Draw track cursor when mouse is moving over plotarea. Hide it when mouse leaves plot area.
    viewer.attachHandler("MouseMovePlotArea", function(e) {
        trackLineLabel(viewer, viewer.getPlotAreaMouseX());
        viewer.setAutoHide("all", "MouseOutPlotArea");
    });
});

//
// Draw track line with data labels
//
function trackLineLabel(viewer, mouseX)
{
    // Remove all previously drawn tracking object
    viewer.hideObj("all");

    // The chart and its plot area
    var c = viewer.getChart();
    var plotArea = c.getPlotArea();

    // Get the data x-value that is nearest to the mouse, and find its pixel coordinate.
    var xValue = c.getNearestXValue(mouseX);
    var xCoor = c.getXCoor(xValue);

    // Draw a vertical track line at the x-position
    viewer.drawVLine("trackLine", xCoor, plotArea.getTopY(), plotArea.getBottomY(), "black 1px dotted");

    // Draw a label on the x-axis to show the track line position
    viewer.showTextBox("xAxisLabel", xCoor, plotArea.getBottomY() + 4, JsChartViewer.Top,
        c.xAxis().getFormattedLabel(xValue, "mmm dd, yyyy"),
        "font:bold 11px Arial;color:#FFFFFF;background-color:#000000;padding:0px 3px");

    // Iterate through all layers to draw the data labels
    for (var i = 0; i < c.getLayerCount(); ++i)
    {
        var layer = c.getLayerByZ(i);

        // The data array index of the x-value
        var xIndex = layer.getXIndexOf(xValue);

        // Iterate through all the data sets in the layer
        for (var j = 0; j < layer.getDataSetCount(); ++j)
        {
            var dataSet = layer.getDataSetByZ(j);

            // Get the color and position of the data label
            var color = dataSet.getDataColor();
            var yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis());

            // Draw a track dot with a label next to it for visible data points in the plot area
            if ((yCoor != null) && (yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY()) &&
                (color != null))
            {
                viewer.showTextBox("dataPoint" + i + "_" + j, xCoor, yCoor, JsChartViewer.Center,
                    viewer.htmlRect(7, 7, color));

                viewer.showTextBox("dataLabel" + i + "_" + j, xCoor + 5, yCoor, JsChartViewer.Left,
                    dataSet.getValue(xIndex).toPrecision(4),
                    "padding:0px 3px;font:bold 10px Arial;background-color:" + color + ";color:#FFFFFF");
            }
        }
    }
}

</script>
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
    Track Line with Data Labels
</div>
<hr style="border:solid 1px #000080" />
<div style="font-size:10pt; font-family:verdana; margin-bottom:1.5em">
    <a href="viewsource.asp?file=<%=Request("SCRIPT_NAME")%>">View Source Code</a>
</div>
<!-- ****** Here is the chart image ****** -->
<%=viewer.renderHTML()%>

</body>
</html>