Form Designer: Define a Formula Control

You can define formulas or functions according to the VB .NET rules. For more information, see http://msdn.microsoft.com/vbasic.

Use the Formula control to add, subtract, multiply or divide values.

Some sample formulas:

Show the FID

result="The FID is " & {FID}& "."

Show the result of any selection

result = Me.ConnectionTools.LngValue("select count(*) from <table> where column=" & LngValue("parent_fid"))

Show whether geometry is available and set the color of the box

if Me.GeometryAvailable then
result="Geometry available"
 Me.ForeColor=""
Me.BackColor=""
else
result="No Geometry available"
Me.ForeColor="white" 'These are HTML colors !
Me.BackColor="red"
end if

Show how many Microsoft documents (DocumentManager) are available and set the color of the box

The temp variable c is used in order to avoid calling the function twice:

dim c as integer
c = me.DocumentCount 
if c=0 then
 result="No Documents available"
Me.BackColor=""
else
 result=c & " Document(s) available"
Me.BackColor="red"
end if
Note: This example shows the concepts. However, it is much easier to use the Document Manager control for this task. See also Form Designer: Document Linker - Properties.

Calculate with attribute values

Result = {HEIGHT} + 20
Result = {HEIGHT} * 20
Result = {HEIGHT} / 20
Result = {HEIGHT} – 20
Combinations with other attribute names are also possible, for example:
Result = {HEIGHT_1} + {HEIGHT_2} *10
Result = {attribute name1} * {attribute name3} *10

Assemble the contents of two text attributes. Delete or add the characters of text fields (data type varchar2)

result = {TEXT1} & {TEXT2}

Append a prefix and a suffix

result = "Approx. " & {AREA} & "m2"

Generate a manhole name from an FID

result = "MH " & {FID}

Calculate the remaining days until next maintenance (using a feature class attribute MAINTENANCE_NEXT_DATE)

Dim d As Date

Dim t As System.TimeSpan
d = Me.Value("maintenance_next_date")
t = d.Subtract(now)
result=t.Days