Search code examples
lotus-notesnotesview

Lotus Notes: Print/write variant() to freefile() .csv


I just want to ask how to print a variant() --> "tmpArray" to .csv? Because in the code that I have right now, it's only accessing the first value in the array. I want to access all the values in the array and print it in .csv file. Below is my code. Would appreciate any suggestions/help. Thanks.

For example I have 3 documents same value.

tmpArray3(0) = 2,999
tmpArray3(1) = 4,999
tmpArray4(0) = 1,000
tmpArray4(1) = 5,903

The one which is being printed for the 1st document is: 2,999 and 1,000. The one which is being printed for the 2nd document is: 2,999 and 1,000. The one which is being printed for the 3rd document is: 2,999 and 1,000.

It's not proceeding to the second value in the variant array.

 Do While doccount1 < 11 AND Not v2entry Is Nothing

            ReDim Preserve tmpArray3(tmpcount3)
            ReDim Preserve tmpArray4(tmpcount4)

            tmpArray3(tmpcount3) = v2entry.ColumnValues(3)
            tmpArray4(tmpcount4) = v2entry.ColumnValues(4)
           

            doccount1 = doccount1 + 1

            tmpcount3=tmpcount3 + 1
            tmpcount4=tmpcount4 + 1
         

            Print #datafileNum%,(tmpArray3(0) & ";" & tmpArray4(0))
            Set v2entry = vc.GetNextEntry(v2entry)

        Loop
    Next
    Close datafileNum%
    Exit Sub


Solution

  • One issue is that in your Print statement you are accessing the first index (i.e. index 0) of the array for tmpArray3 and tmpArray4. You need to put a variable in there instead.

    For example:

     Do While doccount1 < 11 AND Not v2entry Is Nothing
    
                ReDim Preserve tmpArray3(tmpcount3)
                ReDim Preserve tmpArray4(tmpcount4)
    
                tmpArray3(tmpcount3) = v2entry.ColumnValues(3)
                tmpArray4(tmpcount4) = v2entry.ColumnValues(4)
               
    
                doccount1 = doccount1 + 1
                           
    
                Print #datafileNum%,(tmpArray3(tmpcount3) & ";" & tmpArray4(tmpcount4))
                Set v2entry = vc.GetNextEntry(v2entry)
    
                tmpcount3=tmpcount3 + 1
                tmpcount4=tmpcount4 + 1
    
            Loop
        Next
        Close datafileNum%
        Exit Sub

    However, you are also always retreiving index 3 and 4 from the v2entry.ColumnValues(). I assume you want to replace the 3 and 4 with a variable as well