Sep 3rd, 2002, 06:04 AM
#1
Thread Starter
Fanatic Member
byref array
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?
Sep 3rd, 2002, 08:36 AM
#2
PowerPoster
Is your array declared as Public or Private?
Sep 3rd, 2002, 10:33 AM
#3
Thread Starter
Fanatic Member
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)
Attached Files
Sep 3rd, 2002, 10:44 AM
#4
PowerPoster
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
Sep 3rd, 2002, 10:56 AM
#5
Thread Starter
Fanatic Member
Sep 3rd, 2002, 11:03 AM
#6
Thread Starter
Fanatic Member
but what if test is a function ans is declared as:
Code:
public function test (a() as string) as boolean
test = true
end function
Do I have to call my sub like this then
Code:
Dim boolean1 as Boolean
Dim ar(0 To 10) As String
boolean1 = test(ar())
Sep 3rd, 2002, 11:08 AM
#7
PowerPoster
You've got that right.
;-)
Sep 3rd, 2002, 11:10 AM
#8
Thread Starter
Fanatic Member
Originally posted by IROY55
You've got that right.
;-)
thanks for helping me
Sep 3rd, 2002, 11:26 AM
#9
Sep 3rd, 2002, 11:30 AM
#10
Thread Starter
Fanatic Member
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
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width