This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Vb Script to compare and set boolean property

I would like you to assist me do comparison between two properties that are both real numbers in data type. Once the comparison is done I would like to then set a Boolean property that I have already defined as either yes or no depending on the results from the comparison.
The two properties are "sums assured" property id:1097 and "fcl limit" property id: 1098.
After an if condition the a Boolean property named: "sums assured> fcl" property id: 1150, should be set to either yes or no.
Please help.

This is my code so far that doesn't seem to work:

option explicit

Dim sums_assured
Dim myint1
Dim myint2
'Get Sum Assured Value
sums_assured = PropertyValues.SearchForProperty( 1097 ).TypedValue.GetValueAsUnlocalizedText
'Convert to integer
myint1=CInt(sums_assured)
' Get F.C.L. Limit

Dim fcl_limit

fcl_limit = PropertyValues.SearchForProperty( 1098 ).TypedValue.GetValueAsUnlocalizedText
'Convert to intger
myint2=CInt(fcl_limit)

If (myint1 > myint2 ) Then

Output.SetValue MFDatatypeBoolean,0

else

Output.SetValue MFDatatypeBoolean,-1
End If
  • You should not get the values as text as the comparison features greater or smaller won't work correctly when you compare text strings. Get the values as values instead (TypedValue.Value) instead.
  • Finally I got a solution that works. First the script is to be set under the Boolean property's automatic values calculated value (vb script). Here is the code snippet.
    option explicit

    Dim sums_assured
    Dim myint1
    Dim myint2
    sums_assured = PropertyValues.SearchForProperty(1097).TypedValue.Value
    'myint1=CInt(sums_assured)
    ' Get F.C.L. Limit

    Dim fcl_limit

    fcl_limit = PropertyValues.SearchForProperty(1098).TypedValue.Value
    'myint2=CInt(fcl_limit)

    If sums_assured > fcl_limit Then
    'Output = "Automatic value"
    'greaterthan.TypedValue.SetValue MFDatatypeBoolean, True
    Output.SetValue MFDatatypeBoolean,-1
    'greaterthan.SetValue MFDatatypeBoolean, True
    else

    'greaterthan = Output.SetValue MFDatatypeBoolean, False
    Output.SetValue MFDatatypeBoolean,0
    End If
    :)
  • Thanks mika that was very resourceful.