Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Passing an array into a function

Status
Not open for further replies.

todw17

Programmer
Apr 2, 2001
2
US
I want to pass in an array to a function. I have a select statement in which an array is selected based on the value of a counter. I wanted to move out a lot of the redundant code into a new function.

the basic setup is as follows:
Function selectArray(counter)
Select Case counter
Case 0
printArray(AlphaArray())
Case 1
printArray(BetaArray())
Case 2
printArray(GammaArray())
End Select
End Function

If I put all of the "printArray" code inside the Case statements, it works fine. It seemed much nicer to have a seperate function outside the selectArray function.

I'm not sure how to handle this inside the function that recieves the array as a parameter. I keep getting "Type Mismatch" errors. I'm sure this isn't too hard, however I just started using VB, so its all hard for me :).
If someone could provide some syntax I would appreciate it.

Thanks.

** variable and function names have been changed to protect the innocent. :)
 
This may help.
Code:
Dim arrayOfVariants () ' 1st its an array then it is a variant

Dim variantContainingAnArray '1st it is a variant
Redim variantContainingAnArray(0) ' Now it is a variant that contains an array
I've had no trouble with passing a variantContainingAnArray. There is a differece between the two believe me BUT .Net is going to eliminate variants.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top