From: mynamehere@comcast.net   
      
   "Paul" wrote in message   
   news:425a7b88_1@news.iprimus.com.au...   
   > Please help, I am working on an Active-x project involving Arrays with up to   
   > 20 elements populated in a class module. In order to keep programming and   
   > debugging simple, Instead of refering to each element with numbers, would it   
   > be correct to refer to each element with constants as per the example shown   
   > bellow.   
   >   
   > Dim AddrArray(1 To 20, 1 To 3)   
   > Dim Address As clsMyClass   
   > Dim MyStr As String   
   > Dim intX As Integer   
   > Const First = 1   
   > Const Last = 2   
   > Const Phone = 3   
   >   
   > '' with this in a class module called clsMyClass   
   >   
   > Public Function AddrBook(First, Last, Phone, AddrArray())   
   > AddrArray(1, First) = "Joe"   
   > AddrArray(1, Last) = "Bloggs"   
   > AddrArray(1, Phone) = "5551234"   
   >   
   > AddrArray(2, First) = "Sarah"   
   > AddrArray(2, Last) = "Bloggs"   
   > AddrArray(2, Phone) = "5554321"   
   >   
      
   Nothing wrong with using constants to reference array elements.   
      
   Another approach is a user defined type:   
   Public Type Addr   
    First As String   
    Last As String   
    Phone As String   
   End Type   
   Dim AddrArray(1 To 20) As Addr   
   .....   
   AddrArray(1).First = "Joe"   
   AddrArray(1).Last = "Bloggs"   
   AddrArray(1).Phone = "5551234"   
   ...   
   I'm not sure why AddrArray is not *inside* of clsMyClass, and why you are not   
   explicitly typing it as strings, but that is another topic.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|