Solved

Public Arrays

Posted on 2000-03-15
4
279 Views
Last Modified: 2010-05-02
This is probably pretty lame, but I'm stuck.. I declare this in the (General)
part of Form1:

Public Whatever(8) As Integer

I get the error:
Compile Error:
Constants, fixed-length strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules.

I have VB6.0.8169 and the Public statement is the only line of code in my program (currently :)  I looked in my project settings, but I didn't see anything relevent..  I'm trying to pass an array from one form to another in the w/i same project..

Thanks,

Lee
0
Comment
Question by:400lbGorilla
  • 2
4 Comments
 
LVL 20

Expert Comment

by:hes
ID: 2622021
Put the Public Whatever(8) As Integer
in a module instead of in the form.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2622029
Add a Module to your project (Project->Add Module) and there you can declare the public array.  All of your code can then access it directly.

Or declare the array as Private in your form and pass it by reference to other forms.

Option Explicit
Private a(10) As Long

Private Sub Command1_Click()
    'Pass the array to another form's function
    Call Form2.test(s())
End Sub
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2622033
Typo, should be:
Call Form2.test(a())
0
 

Accepted Solution

by:
pinshah earned 100 total points
ID: 2622422
Do this in your form. You will get the feeling of a array and the syntax of a array. Also you can stop someone from going beyound a particular index in this case 8

Private a(8) As Integer

Public Property Let WhatEver(Index As Integer, nValue As Integer)
    a(Index) = nValue
End Property

Public Property Get WhatEver(Index As Integer) As Integer
    WhatEver = a(Index)
End Property


0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question