×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-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.

# Pass two arrays into a sub-program?

## Pass two arrays into a sub-program?

(OP)
I can pass one array into a sub-program, but not two arrays.  Can anybody here tell me what is wrong with the following code?

DECLARE SUB subroutine (a1(), a2() AS INTEGER)
DIM array1(0 TO 12) AS INTEGER
DIM array2(0 TO 3, 0 TO 4) AS INTEGER
subroutine array1(), array2()

SUB subroutine (a1(), a2() AS INTEGER) STATIC
´ does something with two arrays
END SUB

### RE: Pass two arrays into a sub-program?

You have a few syntax errors. It's been quite a few years since I've used QBASIC but this runs in QuickBasic 1.1 and 4.5

#### CODE

DECLARE SUB subroutine (a1() AS INTEGER, a2() AS INTEGER)

DIM array1(0 TO 12) AS INTEGER
DIM array2(0 TO 3, 0 TO 4) AS INTEGER

DECLARE SUB subroutine (array1() AS INTEGER, array2() AS INTEGER)

DIM x AS INTEGER, y AS INTEGER

FOR x = 0 TO 12
array1(x) = x
NEXT

FOR x = 0 TO 3
FOR y = 0 TO 4
array2(x, y) = x * 100 + y
NEXT y
NEXT

CALL subroutine(array1(), array2())

SUB subroutine (a1() AS INTEGER, a2() AS INTEGER) STATIC
' does something with two arrays

DIM x AS INTEGER, y AS INTEGER

CLS

FOR x = 0 TO 12
PRINT a1(x);
NEXT

PRINT

FOR x = 0 TO 3:
FOR y = 0 TO 4
PRINT a2(x, y);
NEXT y
PRINT
NEXT x

END SUB

### RE: Pass two arrays into a sub-program?

In my earlier example, delete the redundant line that reads:

DECLARE SUB subroutine (array1() AS INTEGER, array2() AS INTEGER)

### RE: Pass two arrays into a sub-program?

(OP)
Thanks.

#### 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 Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

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

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!