This event is fired for every value found for the particular answer. This event is fired during the processing of the Answer.IterateValues method.
OnValueFoundEvent (value, repeat1, repeat2, repeat3, repeat4)
Parameter | Description |
VARIANT value | The value found. This VARIANT is interpreted using the same rules as for the Value property. |
long* repeat1 | First repeat index for current value. |
long* repeat2 | Second repeat index for current value. |
long* repeat3 | Third repeat index for current value. |
long* repeat4 | Fourth repeat index for current value. |
The following Visual C# example opens an answer file and displays each answer it contains:
public class ExampleCode { static string ansName; static string ansType; static void Main() { HotDocs.AnswerCollection ac = new HotDocs.AnswerCollection(); ac.Create(@"C:\Documents\HotDocs\Answers\AnswerFile.anx"); Console.WriteLine("Variable\tAnswer\tType"); foreach (HotDocs.Answer ans in ac) { ansName = ans.Name; ansType = getType(ans.Type); ans.OnValueFoundEvent += new HotDocs._AnswerEvents_OnValueFoundEventEventHandler(ans_OnValueFoundEvent); ans.IterateValues(); } Console.ReadKey(); ac.Close(); } static void ans_OnValueFoundEvent(object Value, int repeat1, int repeat2, int repeat3, int repeat4) { string index = ""; string ansValue = ""; if (repeat1 > -1) index = "[" + (repeat1 + 1).ToString() + "] "; //Check to see if the value is an array (multiple-select Multiple Choice variable) if (Value.GetType() == typeof(System.Object[])) foreach (string s in (System.Object[])Value) { ansValue += s + "; "; } else ansValue = Value.ToString(); Console.WriteLine(index + ansName + "\t" + ansValue + "\t" + ansType); } static string getType(HotDocs.HDVARTYPE type) { switch (type) { case HotDocs.HDVARTYPE.HD_DATETYPE: return "Date"; case HotDocs.HDVARTYPE.HD_MULTCHOICETYPE: return "Multiple Choice"; case HotDocs.HDVARTYPE.HD_NUMBERTYPE: return "Number"; case HotDocs.HDVARTYPE.HD_TEXTTYPE: return "Text"; case HotDocs.HDVARTYPE.HD_TRUEFALSETYPE: return "True/False"; default: return type.ToString(); } } }