title: LotusScript: how to iterate numbered fields with for loop
body: <p>I'm using LotusScript to clean and export values from a form to a csv file. In the form there are multiple date fields with names like enddate_1, enddate_2, enddate_3, etc.
  These date fields are <code>Data Type: Text</code> when empty, but <code>Data Type: Time/Date</code> when filled.</p>
  
  <p>To get the values as string in the csv without errors, I did the following (working):</p>
  
  <pre><code>If Isdate(doc.enddate_1) Then 
      enddate_1 = Format(doc.enddate_1,"dd-mm-yyyy") 
  Else
      enddate_1 = doc.enddate_1(0)
  End If
  </code></pre>
  
  <p>But to do such a code block for each date field didnt feel right.</p>
  
  <p>Tried the following, but that isnt working.</p>
  
  <pre><code>For i% = 1 To 9
      If Isdate(doc.enddate_i%) Then 
          enddate_i% = Format(doc.enddate_i%,"dd-mm-yyyy") 
      Else
          enddate_i% = doc.enddate_i%(0)
      End If
  Next
  </code></pre>
  
  <p>Any suggestions how to iterate numbered fields with a for loop or otherwise?</p>