Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print an array with variable dimensions in VB

Status
Not open for further replies.

jackzhong

Structural
Mar 15, 2002
8
Does anyone know how to print an array with variable dimensions in VB?

The following code won't do what I want, it outputs only one column, not rj (10 here) columns.

Open "debug.txt" For Output As #1
rm=10
rj=10
For i = 1 To rm
For j = 1 To rj
Print #1, my_array(i,j)
Next j
Next i
Close #1

What is the right code for my purpose? Thanks for your help.

Jack

 
Replies continue below

Recommended for you

'You need Something like this
dim fileNum as integer
'get the free file number
fileNum= Freefile
Open "debug.txt" For Output As fileNum
'allow for whatever the array has been dimensioned to
rm = ubound(my_array,1)
rj = ubound(my_array,2)
For i = 1 To rm
For j = 1 To rj
print fileNum, my_array(i,j), 'note the trailing commas
Next j
'new line
print fileNum, vbCrLf
Next i
Close #1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor