I took the FieldValidator class and made a subclass, FieldEngine which adds a HiddenFormula list and functions similar to the validation functions to get some HideWhen functionality.
I also modified the settings form to have a HideWhenFormula field that is meant to be like the FieldFormulas field.
'=======================================================
'** FieldEngine Class
'=======================================================
Class FieldEngine As FieldValidator
Private HiddenFormula List As StringPair<br/>
Private hfcount As Long<br/>
<br/>
Private Sub lsdoc_description<br/>
%REM
%END REM
End Sub<br/>
<br/>
'/**<br/>
' * Create a new FieldEngine object, referencing the given fieldName<br/>
' * and using the given default error message if validation fails.<br/>
' */<br/>
Public Sub New (fieldName As String, message As String)<br/>
Me.FieldName = fieldName<br/>
Me.InvalidMessage = message<br/>
isString = True<br/>
AllFormulas = True<br/>
AllPatterns = True<br/>
Set langStrings = New EnglishValidatorLanguageStrings()<br/>
End Sub<br/>
<br/>
Public Function AddHiddenFormula (newFormula As String, errorMessage As String) As FieldValidator<br/>
If (Len(Trim(newFormula)) > 0) Then<br/>
hfcount = hfcount + 1<br/>
Dim sp As New StringPair(newFormula, errorMessage)<br/>
Set HiddenFormula(fcount) = sp<br/>
End If<br/>
Set AddHiddenFormula = Me<br/>
End Function<br/>
<br/>
'/**<br/>
' * Run all validation formulas against the field value<br/>
' */<br/>
Private Function RunFormulaValidation () As Integer<br/>
On Error Goto processError<br/>
<br/>
If (fcount = 0) Then<br/>
RunFormulaValidation = True<br/>
Exit Function<br/>
End If<br/>
<br/>
Dim lastFormula As String<br/>
Dim replaceString As String<br/>
Dim result As Variant<br/>
<br/>
If Me.IsString Then<br/>
replaceString = |"| & fieldValue & |"|<br/>
Elseif Me.IsNumber Then<br/>
replaceString = fieldValue<br/>
Else<br/>
replaceString = |[| & fieldValue & |]|<br/>
End If<br/>
<br/>
Dim f As String<br/>
Forall vf In ValidFormula<br/>
lastFormula = vf.string1<br/>
result = TestFormula(lastFormula)<br/>
result = Cint(result(0))<br/>
<br/>
If (result = 1) And Not AllFormulas Then<br/>
' * only a single success required<br/>
RunFormulaValidation = True<br/>
Exit Function<br/>
Elseif (result = 0) And AllFormulas Then<br/>
' * a single failure means the whole thing failed<br/>
returnString = vf.string2<br/>
failureString = langStrings.FORMULA_VALIDATION_ERROR & ": " & lastFormula<br/>
Exit Function<br/>
End If<br/>
End Forall<br/>
<br/>
If AllFormulas Then<br/>
' * all formulas required, and none of them failed<br/>
RunFormulaValidation = True<br/>
Else<br/>
' * only one success required, and nothing worked<br/>
failureString = langStrings.FORMULA_NO_MATCHES_ERROR<br/>
End If<br/>
Exit Function<br/>
<br/>
processError:
failureString = langStrings.FORMULA_RUNTIME_ERROR & ": " & lastFormula<br/>
Exit Function<br/>
End Function<br/>
<br/>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br/>
'<br/>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' <br/>
Function Hidden As Boolean<br/>
On Error Goto processError<br/>
Hidden = Check(HiddenFormula, True)<br/>
<br/>
Exit Function<br/>
<br/>
processError:
failureString = langStrings.FORMULA_RUNTIME_ERROR & ": " & lastFormula<br/>
Exit Function<br/>
End Function<br/>
<br/>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br/>
'<br/>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' <br/>
Function TestFormula(Formula As String) As Boolean<br/>
On Error Goto processError<br/>
<br/>
Dim lastFormula As String<br/>
Dim replaceString As String<br/>
Dim result As Variant<br/>
Dim t As String<br/>
<br/>
If Me.IsString Then<br/>
replaceString = |"| & fieldValue & |"|<br/>
Elseif Me.IsNumber Then<br/>
replaceString = fieldValue<br/>
Else<br/>
replaceString = |[| & fieldValue & |]|<br/>
End If<br/>
<br/>
lastFormula = Formula<br/>
t = Replace(Formula, |@ThisValue|, replaceString)<br/>
result = Evaluate(t, doc)<br/>
TestFormula = Cint(result(0))<br/>
<br/>
Exit Function<br/>
<br/>
processError:
failureString = langStrings.FORMULA_RUNTIME_ERROR & ": " & lastFormula<br/>
Exit Function<br/>
End Function<br/>
<br/>
<br/>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br/>
'<br/>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' <br/>
Function CheckUntil(Formulas As Variant, flag As Boolean) As Boolean<br/>
On Error Goto processError<br/>
<br/>
Dim lastFormula As String<br/>
Dim replaceString As String<br/>
Dim result As Variant<br/>
Forall f In Formulas<br/>
lastFormula = f.string1<br/>
result = TestFormula(f.string1)<br/>
If result = flag Then<br/>
CheckUntil = True<br/>
Exit Function<br/>
End If<br/>
End Forall<br/>
<br/>
Exit Function<br/>
<br/>
processError:
failureString = langStrings.FORMULA_RUNTIME_ERROR & ": " & lastFormula<br/>
Exit Function<br/>
End Function<br/>
<br/>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br/>
'<br/>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' <br/>
Function Check(Formulas As Variant, flag As Boolean) As Boolean<br/>
On Error Goto processError<br/>
<br/>
Dim lastFormula As String<br/>
Dim replaceString As String<br/>
Dim result As Variant<br/>
Forall f In Formulas<br/>
lastFormula = f.string1<br/>
result = TestFormula(f.string1)<br/>
If result = flag Then<br/>
Check = True<br/>
End If<br/>
End Forall<br/>
<br/>
Exit Function<br/>
<br/>
processError:
failureString = langStrings.FORMULA_RUNTIME_ERROR & ": " & lastFormula<br/>
Exit Function<br/>
End Function<br/>
<br/>
<br/>
End Class