array problem

J

Jean-Yves Simon

Hi all,

I have a little problem with an array. Here is what I am doing


Function foo(N1 As String) As String
Dim MyResult As String
Dim S1(64) As String
Dim S2(64) As String
Dim S3(64) As String
Dim S4(64) As String
Dim S5(64) As String
Dim S6(64) As String
Dim S7(64) As String
Dim S8(64) As String

'init array

S1(0) = "1110"
S1(2) = "0100"
.... and so on

When I do that, I have an error
"compile error"
invalid outside procedure"

I clicked on the help button to try to understand but I dont
get it why I have this error. Is this not a proper way to init
an array ?
 
T

Tushar Mehta

What line does the VBE point to when it pops up with the error message?
The message typically means that you have some kind of unacceptable
statement outside of the scope of any sub/function.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
J

Jean-Yves Simon

Tushar said:
What line does the VBE point to when it pops up with the error message?
The message typically means that you have some kind of unacceptable
statement outside of the scope of any sub/function.
Hi,

Thanks for replying. The error is on the first line where I init
the array ie:

S1(0) = "1110"

Thanks and regards
Jean-Yves.

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

--
--
Jean-Yves SIMON E-mail : [email protected]

==================================================================
Jean-Yves Simon TEXAS INSTRUMENTS FRANCE
WTBU Platform and IC Development Tel : +33 (0)4.93.22.29.60
Cel : +33 (0)6.78.41.67.82
mailto:[email protected] Fax : +33 (0)4.93.22.22.75
==================================================================
 
B

Bill Plenge

Jean-Yves Simon said:
Hi,

Thanks for replying. The error is on the first line where I init
the array ie:

S1(0) = "1110"

Thanks and regards
Jean-Yves.

Are you certain the sample code you posted is a correct recreation of the
problem? If I cut and past it into Excel XP or VB6, once I add an end
function it runs just fine using a test call of Result$ = foo("Test"). Can
you post the actual code that has the problem? From the error you're
describing it sounds as if the code assigning the values isn't inside a
procedure (Sub or Function.)

Best,
Bill
 
Top