Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / July 2008



Tip: Looking for answers? Try searching our database.

Passing an array to a sub

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
charles@home.com - 29 Jul 2008 12:11 GMT
I would like to pass an array to a sub and have the following code:

Public Sub callMySub(inputData() as string)
   'some lines of code
End Sub

From inside another sub I have...
    Dim theData() As String
    theData = Split(Text1.Text, vbCrLf)
    callMySub (theData())

I dont need to make any changes to the data in the array that is being
passed.
I just need to step thru the array looking for a particular string.

I get an error message saying "array argument must be by reference"

Can someone explain what I'm doing wrong.

Thanks

Charles W
Norm Cook - 29 Jul 2008 12:47 GMT
>I would like to pass an array to a sub and have the following code:
>
[quoted text clipped - 14 lines]
>
> Can someone explain what I'm doing wrong.

Change the line callMySub (theData()) to:
Either
 callMySub theData() or callMySub theData
Or
 Call callMySub (theData()) or Call callMySub (theData)

Just my $.02 but the name of the function (callMySub)
is somewhat confusing.  I would change it to something
like MySub or something more descriptive of what it does
to the string array.
charles@home.com - 29 Jul 2008 13:52 GMT
Thanks.

Charles W

>>I would like to pass an array to a sub and have the following code:
>>
[quoted text clipped - 25 lines]
> like MySub or something more descriptive of what it does
> to the string array.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.