×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to print an array with variable dimensions in VB

How to print an array with variable dimensions in VB

How to print an array with variable dimensions in VB

(OP)
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

RE: How to print an array with variable dimensions in VB

'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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close