Code to Apply Data Type Conversion and Range-Checking

This topic describes how to create an Active Server Pages (ASP) page (Form.asp) that contains a form whose contents are checked and converted to a Date Variant. The checking and conversion are performed by the Process.asp file.

The first parameter to the RequestDate method specifies, in the following example, the name of the form field from which the data was submitted. If this text field is empty, the second parameter to the RequestDate method, "1/1/2000", becomes the date that the RequestDate method processes. First, the string expression of the date is converted to a date value based on a specified Locale property (1033, the Locale property for the US, in this instance), and then the value is checked against the specified date range specified by the third and fourth parameters.

If the Form.asp file is loaded into the browser, it will display the date as processed by the RequestDate method in the Process.asp file.

  1. Create the Form.asp file using the following code:

    <FORM METHOD="POST" ACTION = "Process.asp">
    <INPUT TYPE="Text" NAME= "Date">
    <INPUT TYPE ="Submit" NAME = "Action" VALUE = "Send Info"
    </FORM>
    
  2. Create the Process.asp file using the following code:

    Dim oAppFrameWork, vDate
    Set oAppFrameWork = Server.CreateObject("Commerce.AppFrameWork")
    vDate = oAppFrameWork.RequestDate("Date", _
                                         "1/1/2000", _
                                         "1/1/2000",  _
                                         "12/12/2000", _
                                         "1033")
    If IsNull(vDate) Then
        Response.Write "Invalid Date"
    Else
        Response.Write vDate
    End If
    

Copyright © 2005 Microsoft Corporation.
All rights reserved.