Share via


Code to Display Locale-Specific Strings

This section describes how to create Active Server Pages (ASP) pages that use the string conversion functions of the DataFunctions object.

Converting a Date Based on Locale

Converting a Number Based on Locale

Converting a Money Amount Based on Locale

Converting a Date Based on Locale

In this example, you create an ASP page that converts a date into two locale-specific displays. The first display is that of the French version of the date; the second is the US version.

Create this example using the following ASP code:

  1. Instantiate the DataFunctions object, set the Locale property to France (1036), convert the date string, and write the converted string to the page.

    Dim Result, Amount
    Amount = "12000"
    Set oDataFunctions = Server.CreateObject("Commerce.DataFunctions")
    iLocale = "1036"
    oDataFunctions.Locale = iLocale
    Result = oDataFunctions.ConvertDateString("12/1/2000", iLocale)
    Response.Write "France: " & Result & "<BR>"
    
  2. Set the Locale property to US (1033), convert the date string, and write the converted string to the page.

    iLocale = "1033"
    oDataFunctions.Locale = iLocale
    Result = oDataFunctions.ConvertDateString("12/1/2000", iLocale)
    Response.Write "USA: " & Result & "<BR>"
    

Converting a Number Based on Locale

In this example, you create an ASP page that converts a floating-point number into two locale-specific outputs. The first output is that of the French version of the number; the second is the US version.

The output shows the differing display formats of the French and US versions of the number 10000000 (ten million):

  • France: 10 000 000,00
  • US: 10,000,000.00

Create the ASP page using the following code:

  1. Instantiate the DataFunctions object.

    Dim oDataFunctions, sResult, iLocale
    Set oDataFunctions = Server.CreateObject("Commerce.DataFunctions")
    
  2. Set the Locale property to France (1036), and write the converted number to the page.

    iLocale = "1036"
    oDataFunctions.Locale = iLocale
    sResult = oDataFunctions.Number(10000000, iLocale)
    Response.Write "France: " & sResult & "<BR>"
    
  3. Change the Locale property to US (1033), and write the converted number to the page.

    iLocale = "1033"
    oDataFunctions.Locale = iLocale
    sResult = oDataFunctions.Number(10000000, iLocale)
    Response.Write " USA: " & sResult & "<BR>"
    

Converting a Money Amount Based on Locale

In this example, you create an ASP page that converts a floating-point number that contains a monetary value into two locale-specific displays. The first display is that of the French version of the number; the second is the US version.

Use this method to convert a long that contains a monetary value to an equivalent string representation, based on the default or specified Locale property. The output will display the locale-specific currency symbol:

  • France: 120,00 F
  • US: $120.00

Create this example using the following ASP code:

  1. Instantiate the DataFunctions object.

    Dim oDataFunctions, sResult, lAmount
    Amount = "12000"
    Set oDataFunctions = Server.CreateObject("Commerce.DataFunctions")
    
  2. Set the Locale property to France (1036), convert the amount, and write the result to the page.

    iLocale = "1036"
    oDataFunctions.Locale = iLocale
    sResult = oDataFunctions.Money(lAmount, iLocale)
    Response.Write "France: " & sResult & "<BR>"
    
  3. Set the Locale property to US (1033), convert the amount, and write the result to the page.

    iLocale = "1033"
    oDataFunctions.Locale = iLocale
    sResult = oDataFunctions.Money(lAmount, iLocale)
    Response.Write "USA: " & sResult & "<BR>"
    

Copyright © 2005 Microsoft Corporation.
All rights reserved.