Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 4th, 2005, 05:25 AM
Registered User
 
Join Date: Nov 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default declaring public array

Hi;

i search thru the forum but failed to find the solution that i want...
i am using vb6, my problem is i would like to declare a public array with 2 dimension, but an error message prompted and tell me that it is not allowed to do so, so after searching the net i using the LET and GET method but i still not really know how to use it, can someone help? below is my code:

************************************************** *******
in my class1:

Private GraphicArr(1 To 2, 50) As String

Public Property Get GArray(ShpType As Integer, ShpNo As Integer) As String
GArray = GraphicArr(ShpType, ShpNo)
End Property

Public Property Let GArray(ShpType As Integer, ShpNo As Integer, Value As String)
GraphicArr(ShpType, ShpNo) = Value
End Property
************************************************** ******

i would like to know in my main form, how can i set the value by calling the GArray and how do i call back to retrieve the value?

really need your help, please......

Thanks
 
Old January 4th, 2005, 03:45 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What is the message of the error that you receive?
How are you pressing this class into service in your form? (Please show the code, I mean)
 
Old January 4th, 2005, 09:37 PM
Registered User
 
Join Date: Nov 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually i would like to declare this array as public because i will need this array in my class later, will first assign this array some value from my main form, then use the value in my class to do some processing. At first, i declared it as Public GraphicArr(1 to 2, 0 to 49) as String, then an error message prompted out:

Compile error:
Constans, Fixed-Length Strings, Arrays, User-Defined types and Declare statements not allowed as Public members of object modules.

do i miss out something when declaring my array? and can this public array be used in my class?

by the way, i had tried to do this in my form:
Dim GraphicArrayCls As Class1
Dim GraphicArr() As String

Set GraphicArrayCls = New Class1

ReDim GraphicArr(1 To 2, 1 To 20)
GraphicArr(1, 20) = GraphicArrayCls.GArray(1, 20)

For cnt = 1 to 20
  GraphicArr(1, cnt) = stringvalue
next
......

this code can be compile but it will stop when it reach
GraphicArr(1, 20) = GraphicArrayCls.GArray(1, 20)

 please help...





Similar Threads
Thread Thread Starter Forum Replies Last Post
public article - public articledetails _keysersoze_ BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 8th, 2007 08:38 AM
Declaring a dropdownlist Rod Merritt BOOK: ASP.NET Website Programming Problem-Design-Solution 0 August 1st, 2006 02:11 PM
declaring structs scoobie C++ Programming 3 April 6th, 2006 12:44 AM
declaring variables that are not used crmpicco VB How-To 2 May 19th, 2005 04:22 PM
Declaring and instantiating... jacob ASP.NET 1.0 and 1.1 Basics 4 August 21st, 2003 10:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.