Solved

Public Arrays

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now