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,403 of 10,840   
   Steve Gerrard to Paul   
   Re: Using variables to reference Array e   
   11 Apr 05 08:13:42   
   
   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)   

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


(c) 1994,  bbs@darkrealms.ca