In place of NL, use the built in VB
constant vbCrLf. It is exactly the same thing.
Un-indented code is really
hard to read . . .
Your ReDim would be clearer as
ReDim x(0 To n - 1, 0 To 1) As String
The best way to generate text files (in my opinion) is to add a reference in your project to the Windows Scripting host, then create an instance of a FileSystemObject that that refernce provides. Then create a text-stream object, and use the obj.WriteLine method to write lines into the file. (Or use the .Write method, which does not generate a new line automatically.)
I believe that to find the primary key and so on, you will need to look through (I believe) the indexes collection of the database, armed with your table name.