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?
Is your array declared as Public or Private?
private in my first sub, but when I pass it byref, It should be private, or else it is not realy passing it.
check attachment. (This is not the real program but I just made it to test it)
I've found 2 things:
For i = 0 To 10
ar(1) = i
Next i
test (ar)
1. It must be ar(i) = i - not ar(1) = i
2. You are passing it wrong: instead of test (ar) type test ar()
Also in your Test sub try not to hardcode any number, but instead use Ubound(a) for your loop.
Roy
thanks
but what if test is a function ans is declared as:
Do I have to call my sub like this thenCode:public function test (a() as string) as boolean
test = true
end function
Code:Dim boolean1 as Boolean
Dim ar(0 To 10) As String
boolean1 = test(ar())
You've got that right.
;-)
thanks for helping meQuote:
Originally posted by IROY55
You've got that right.
;-)
The only problem was the parenthesis. You had test (ar) and should be test ar. And if it were a funtion Ans = test(ar) is enough
thanks
I knew it was a problem with the parentheses (i've had the same porblem with C++) but I didn't really know how to do it
But hat i do not understand is why it did work when it was all in 1 module