Sample Scripts

Scripts can be used to transform property values during the ERM process.

  1. To change a property value to uppercase:

    TextOut = UCase(PropertyValue)

  2. To replace a value with a null value (replace “$” with null):

    TextOut = replace(PropertyValue, "$", "")

  3. To transform a property value (INV) to a different value (Invoice):

    if (ucase(PropertyValue) = "INV") then

    TextOut = "Invoice"

    end if

  4. To strip the first three characters of a property if the length of the property is greater than 3:

    if (len(PropertyValue) > 3) then

    TextOut = right(PropertyValue, len(PropertyValue) – 3)

    else

    TextOut = PropertyValue

    end if

  5. To strip the first character of a property if the value is not numeric:

    if (IsNumeric(left(PropertyValue, 1) ) ) then

    TextOut = PropertyValue

    else

    TextOut = right(PropertyValue, len(PropertyValue) -1)

    end if

  6. To extract a value that floats on the page (in this example an order total that looks like "** ORDER TOTAL **    1603.95"):

    'Declare variables used in script.

    Dim strText

    Dim strNumb

    Dim strSearch

    Dim strTemp

    Dim intPos

    Dim i

    'If not value found in Property Value, then exit.

    if Len(PropertyValue) = 0 then

       Exit Function

    end if

    'String to search for.

    strSearch = "** ORDER TOTAL **"

    'Put text found in variable for manipulation.

    strText = PropertyValue

    'Search for "** ORDER TOTAL **" in text.

    intPos = InStr(1, strText, strSearch, vbTextCompare)

    'If header string not found, then exit.

    if intPos = 0 then

       Exit Function

    end if

    'Trim off header.

    strText = Trim(Right(strText, Len(strText) - (intPos + Len(strSearch))))

    'Loop through remaining text to dig out number.

    For i = 1 To Len(strText)

       strTemp = Mid(strText, i, 1)

  7. 'If it is numeric, then build number string.

    If IsNumeric(strTemp) Then

       strNumb = strNumb & strTemp

    'Make sure we include decimal in number.

    Else if strTemp = "." Then

       strNumb = strNumb & strTemp

    Else

    'Number is done, so exit loop.

       Exit For

      End If

    End If

    Next

    'Return the results.

    TextOut = strNumb


Other ERM Information