Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    8

    Question Unanswered: 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

  2. #2
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447
    As far as I know, you are only allowed to use one dimension using Get/Let properties. So, I would rewrite you code like this:

    1st approach: just publishing strings:

    Private GraphicArr1(50) As String
    Private GraphicArr2(50) As String

    Public Property Get GArray1(ShpNo As Integer) As String
    GArray = GraphicArr1(ShpNo)
    End Property
    Public Property Let GArray1(ShpNo As Integer, Value As String)
    GraphicArr1(ShpNo) = Value
    End Property

    Public Property Get GArray2(ShpNo As Integer) As String
    GArray = GraphicArr2(ShpNo)
    End Property
    Public Property Let GArray2(ShpNo As Integer, Value As String)
    GraphicArr2(ShpNo) = Value
    End Property


    However, you may also consider to do:

    Public Type StringArrayType
    Item(1 to 50) as string
    end type

    Private GraphicArr(1 To 2) As StringArrayType

    Public Property Get GArray(ShpType As Integer) As StringArrayType
    GArray = GraphicArr(ShpType)
    End Property

    Public Property Let GArray(ShpType As Integer, Value As StringArrayType)
    GraphicArr(ShpType) = Value
    End Property
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •