?
Solved

Public Arrays

Posted on 2000-03-15
4
Medium Priority
?
285 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 300 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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

800 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