AllExperts > Qbasic, Quickbasic 
Search      
Qbasic, Quickbasic
Volunteer
Answers to thousands of questions
 Home · More Qbasic, Quickbasic Questions · Answer Library  · Encyclopedia ·
More Qbasic, Quickbasic Answers
Question Library

Ask a question about Qbasic, Quickbasic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Alex Barry
Expertise
I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, c/c++, python, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

Experience
Hobby programming since 2000

I no longer belong to any community programming groups, but do have knowledge of *basic dialects and C/C++

 
   

You are here:  Experts > Computing/Technology > Basic > Qbasic, Quickbasic > array in qbasic function

Qbasic, Quickbasic - array in qbasic function


Expert: Alex Barry - 9/16/2009

Question
Is it possible to pass array as an argument/parameter in qbasic function? if yes, please let me know. Thanks. With Regards,
Ranj

Answer
Hi, Ranj,

Yes, to pass an array to a SUB/FUNCTION, this is what you'd need to do:

DECLARE SUB PassArray( yourArray%() )

DIM anArray%(1 TO 10)
DIM i AS INTEGER

RANDOMIZE TIMER
FOR i = 1 TO 10
 anArray%( i ) = rnd * 100
NEXT i

' If this causes an error, it may be that you just use
' PassArray( anArray% )
' I think later versions let you do the above line, but
' I'm not completely sure on that one.
PassArray( anArray%() )

SUB PassArray( yourArray%() )
 DIM min AS INTEGER
 DIM max AS INTEGER
 DIM i AS INTEGER

 min = LBOUND( yourArray% )
 max = UBOUND( yourArray% )
 FOR i = min TO max
   PRINT "Array Index:"; i; " = "; yourArray%( i )
 NEXT i
END SUB


I hope that helps,
-Alex

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.