pass an array as function/sub argument 
Author Message
 pass an array as function/sub argument

how to pass an array as an argument to the function/sub procedure??

Sub Main()
 Dim X(5) As Integer
 'do something on X

 '2 attempts: but compile errors
 printArray(X)
 printArray((X))
End Sub

Private Sub printArray(param1() As Integer)
 'do something on array param1
End Sub



Tue, 18 Oct 2005 09:48:05 GMT  
 pass an array as function/sub argument


Quote:
> how to pass an array as an argument to the function/sub
procedure??

> Sub Main()
>  Dim X(5) As Integer
>  'do something on X

    printArray X
> End Sub

> Private Sub printArray(param1() As Integer)
>  'do something on array param1
> End Sub



Tue, 18 Oct 2005 12:46:35 GMT  
 pass an array as function/sub argument
John,

I would do it like this:

Private Sub DoSomething(ByVal x As Integer())

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load

Dim x(5) As Integer

DoSomething(x)

End Sub

Sam Matzen


Quote:
> how to pass an array as an argument to the function/sub procedure??

> Sub Main()
>  Dim X(5) As Integer
>  'do something on X

>  '2 attempts: but compile errors
>  printArray(X)
>  printArray((X))
> End Sub

> Private Sub printArray(param1() As Integer)
>  'do something on array param1
> End Sub



Tue, 18 Oct 2005 12:58:03 GMT  
 pass an array as function/sub argument

Quote:
> how to pass an array as an argument to the function/sub procedure??

is this vb or vb.net?  you have posted to one group for each language and
the answer is different depending on which you need.


Tue, 18 Oct 2005 20:58:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. pass an array as function/sub argument

2. Passing arguments into functions that expect an array

3. Question on passing array parameters to VB.NET Sub/Function

4. Passing array back from Sub/Function

5. Passing arrays to SUBs and FUNCTIONs

6. Passing arrays from a server-function/sub to a server -variable

7. Pass control array to sub/function ?

8. Passing Arrays to Sub / Functions

9. Passing Control Array to a SUB/FUNCTION

10. Passing arrays in a sub/function

11. Passing Arguments / Passing an Array

12. Passing an Argument to a Sub

 

 
Powered by phpBB® Forum Software