Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I did some research on the matter after coming back to work off the weekend, and apparently VBA not getting along with .NET is the issue. According to <a href="http://support.microsoft.com/kb/327084" rel="nofollow">this MSDN article</a> and also stated in <a href="http://forums.devx.com/showthread.php?t=56278" rel="nofollow">this DevX forum thread</a>, it seems it doesn't like method parameters with an array passed by reference and wants them passed by value instead. There's a workaround for VB.NET code in that MSDN article where you simply tell it to pass the set value by value, but defining parameters for accessors in C# doesn't seem to be possible.</p> <p>My solution was to make the Fields property be read-only, and have seperate methods for setting either a single element or the whole shebang.</p> <pre class="lang-cs prettyprint-override"><code>//Added these to the interface. [DispId(aNumber)] void SetField(int index, string value); [DispId(aNumber)] void SetFields(ref string[] fields); //Added these two methods to the class, //and removed the set accessor from the Fields property /// &lt;summary&gt; /// Set a field at the given index with a given value. /// &lt;/summary&gt; /// &lt;param name="index"&gt;Zero-based index of the field to set.&lt;/param&gt; /// &lt;param name="value"&gt;The value to set the field with.&lt;/param&gt; public void SetField(int index, string value) { if (_fieldSizes[0][0] == -1 || (value.Length &gt; _fieldSizes[index][0] &amp;&amp; value.Length &lt; _fieldSizes[index][1])) _fields[index] = value.ToCharArray(); else throw new ArgumentException("value", "Attempt to set a field with a value longer or shorter than the expected length."); } /// &lt;summary&gt; /// Sets all the fields with the values in an array. /// &lt;/summary&gt; /// &lt;param name="fields"&gt;An array of strings containing the values.&lt;/param&gt; public void SetFields(ref string[] fields) { for (int i = 0; i &lt; fields.Length; i++) SetField(i, fields[i]); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload