home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,402 of 10,840   
   Paul to All   
   Using variables to reference Array eleme   
   11 Apr 05 23:28:36   
   
   From: paulp@mindless.com   
      
   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.   
      
   Option Explicit   
   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   
      
   Sub Main()   
       Set Address = New clsMyClass   
       Address.AddrBook First, Last, Phone, AddrArray()   
       For intX = 1 To 4   
       MsgBox AddrArray(intX, First) & vbCr & AddrArray(intX, Last) & vbCr &   
   AddrArray(intX, Phone)   
       Next intX   
   End Sub   
      
   '' 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"   
      
       AddrArray(3, First) = "John"   
       AddrArray(3, Last) = "Doh"   
       AddrArray(3, Phone) = "5551111"   
      
       AddrArray(4, First) = "Jane"   
       AddrArray(4, Last) = "Doh"   
       AddrArray(4, Phone) = "5554444"   
   End Function   
      
   '' Please note: hard-coded for simplicity   
      
   If there is a simpler way of doing this, I would greatly appreciate any   
   help,   
      
   Thanks in advance   
      
   Paul   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca