Solved

Public Arrays

Posted on 2000-03-15
4
282 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

679 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