Previous in Contents Next in Contents

DataFunctions.CleanString Method

The CleanString method processes a string, based on the specified locale. This string processing can include stripping out leading and trailing white spaces, modifying the case of the string, and validating that the length of the string falls within a given range. If successful, CleanString returns the processed string; otherwise, Null.

Syntax

DataFunctions.CleanString(String, MinLength, MaxLength, StripWhiteSpaces, StripReturn, Case, Locale)

Parameters

String
The text of the string to process.
MinLength
Optional. This parameter indicates the minimum length against which the length of String must be validated. The default value for this parameter is zero (0).
MaxLength
Optional. This parameter indicates the maximum number against which the length of String must be validated. The default value for this parameter is no limit.
StripWhiteSpaces
Optional. This parameter is a Boolean value that indicates whether leading and trailing white spaces should be stripped from String. The default value is True.
StripReturn
Optional. This parameter is a Boolean value that indicates whether the carriage returns contained anywhere in String should be stripped. The default value is True.
Case
Optional. This parameter indicates the case to which the string should be converted. The default value for this parameter is zero (0), which results in no modification to the case of the string. If Case is 1, the string is converted to uppercase. If Case is 2, the string is converted to lowercase.
Locale
Optional. This number specifies the locale to use to process the string. If this parameter is not specified, the value of the DataFunctions object's Locale property is used.

Example

The following represents a sample call to CleanString:

Set MSCSDataFunctions = Server.CreateObject("Commerce.DataFunctions")
MSCSDataFunctions.Locale = &H0409
Dim Result
Dim strData
strData = " Microsoft Press   "
Result = MSCSDataFunctions.CleanString(strData, 1, 20, True, True, 1)
Response.Write chr(34) & Result & chr(34) 

The values passed to CleanString in this example indicate that the value in strData should be range-tested to ensure that it is at least one character and no more than 20 characters, that any leading or trailing white spaces should be removed, that any carriage returns in the string should be removed, and that the string should be converted to uppercase. Because the Locale parameter is not specified in the call to CleanString, the method defaults to the value specified in the DataFunctions object's Locale property.

The preceding example produces the following text:

"MICROSOFT PRESS"

Related Topics


© 1997-2000 Microsoft Corporation. All rights reserved.