Writing a 2D numeric array to a file

K

Kelly

Hi all,

I am trying without much success to understand someone else's VB
program. To make things a little easier to compare side by side, I
wanted to print some of the variables being used within the program to
a file. However, I haven't been able to figure out how to create a
simple output file. I tried inserting the following code just below
the calculations in which I am interested. The code compiles and runs
without error, and my little test message box appears with the correct
pathname, but the file doesn't seem to be created. Can anyone spot
the (probably inanely trivial) error in the code below? GrpData is a
2D numeric array, dbFilepath is a string, all other variables are
declared below.

For the record, I am working with Visual Basic 6.0.

'***** KK *****

'Print GrpData array to file grpadataX.txt, where X is
the group
'index. In this array, the first column represents
the
'simulation data, and the remaining columns hold time
series
'data. All data is stored in one-month increments.

'Declarations

Dim kk As Integer
Dim itime As Integer
Dim iser As Integer
Dim kkfilename As String

'Create file and write data

kkfilename = dbFilepath + "grpdata.txt"
kk = 1
Open kkfilename For Output As #kk
For iser = 0 To NSeries
For itime = 1 To Ntimes
Write #kk, GrpData(iser, itime)
Next
Write #kk,
Next
Close #kk
MsgBox "File should be there now: " + kkfilename

'***** KK *****

Thanks,
Kelly
 
C

Cor Ligthert [MVP]

Hi Kelly,

This is not a VB6 or older newsgroup.

Probably in a newsgroup for that they are waiting to help you, one of the
best is

microsoft.public.vb.general.discussions

Cor
 
K

Kelly

Oops, sorry, missed the dotnet part of the name when I did my search.
I'll transfer over.

Thanks,
Kelly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top