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
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