Solved

Public Arrays

Posted on 2000-03-15
4
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

739 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