This example shows the use of the <VbsDbExecute> and <VbsDbFieldParameter> elements within the ViewFieldFormats property.
As you can see, the UnitPrice is displayed in green when the unit price is less than 20$, otherwise it is displayed in red.

To do this, a PriceColor function is defined in the asp page (see below the PriceColor function VBScript code). Such function is invoked for each Grid row: this is done by the <VbsDbExecute>PriceColor(...)</VbsDbExecute> statement in the ViewFieldFormats assignment. PriceColor returns the string "green" if the passed parameter is a number smaller than 20, "red" otherwise.
Each time the PriceColor function is invoked, the current record UnitPrice field value is passed to the PriceColor function: this is done by the <VbsDbFieldParameter>UnitPrice</VbsDbFieldParameter> statement in the ViewFieldFormats assignment.
  ProductName QuantityPerUnit UnitPrice
1 Chai 10 boxes x 20 bags 18
2 Chang 24 - 12 oz bottles 19
3 Aniseed Syrup 12 - 550 ml bottles 10
4 Chef Anton's Cajun Seasoning 48 - 6 oz jars 22
5 Chef Anton's Gumbo Mix 36 boxes 21.35
ProductName Chai
QuantityPerUnit 10 boxes x 20 bags
UnitPrice 18
 First   Prev   Next   Last   Search 
This is the code implementing the example:
<!--#include file="VBSdb/inc.asp"-->
<%
   VbsDbNew objVbsDb
   objVbsDb( "MdbPath" ) = constMdbPathForExamples
   objVbsDb( "Sql" ) = "select ProductName,QuantityPerUnit,UnitPrice from Products"
   objVbsDb( "ViewFieldFormats" ) = "UnitPrice|<font color=" & _
      "<VbsDbExecute>PriceColor(<VbsDbFieldParameter>UnitPrice</VbsDbFieldParameter>)</VbsDbExecute>" & _
      ">{{UnitPrice}}</font>"

   VbsDb objVbsDb
%>
This demonstrative program connects to Nwind.mdb, the well known Microsoft Access sample database: the names of companies, products, people, characters, and/or data mentioned herein are fictious and are in no way intended to represent any real individual, company, product, or event. To download a copy of Nwind.mdb, please visit Microsoft's site.
This is the code implementing the PriceColor function:
   '***********************************************
   function PriceColor( strUnitPrice )
   '***********************************************
      if cDbl( strUnitPrice ) < 20 then
         PriceColor = "green"
      else
         PriceColor = "red"
      end if
   end function