I tried to pass an array of strings to another sub (in another module) as byref value (byval is impossible) this dindn't work
But if I do exactly the same but the 2 subs are in the same module , it does work
could somebody help me?
Printable View
I tried to pass an array of strings to another sub (in another module) as byref value (byval is impossible) this dindn't work
But if I do exactly the same but the 2 subs are in the same module , it does work
could somebody help me?
It's OK with me..
can you give an example.....?
by the way another way of doing it would be to join the elements of the array together with vbNullChar's then send it to your fuinction, then in the function split them again...that would solve your problem...thats how most of the API does it ;)
check attachment
calling a sub including the ( and ) surrounding its parameters forces by val which is why is shows you an error, remove the surrounding ( )'s and you are ok...
also replace the (1) with (i) in the loop...
i have highlighted the code that i have changed....
VB Code:
Option Explicit Private Sub Form_Load() Dim ar(0 To 10) As String Dim i As Integer For i = 0 To 10 'ar(1) = i - INCORRECT [b]ar(i) = i[/b] ' - CORRECT Next i 'Test (ar) - INCORRECT [b]Test ar[/b] ' - CORRECT End Sub Public Sub Test(a() As String) Dim i As Integer For i = 0 To 10 MsgBox a(i) Next i End Sub
:)
thanks, but i've allready sorted it out
can you tell us all how did you sort it out please?