Re: fixed or dynamic array

Tech-Archive recommends: Fix windows errors by optimizing your registry



"George Hester" <hesterloli@xxxxxxxxxxx> wrote in message
news:eVUMKiakIHA.980@xxxxxxxxxxxxxxxxxxxxxxx
I have the following in a VB program:
Dim aList
aList = Split(sList, ";", -1, vbTextCompare)
My question is aList a dynamic or fixed array?

It is a dynamic array. However, it is not a standard dynamic array of strings. It is actually held in a Variant because you did not specify the required variable type when you declared the variable aList, and it therefore defaulted to being a Variant. Variants can occasionally be quite useful, and they are perfectly capable of holding all sorts of things, including arrays, but in general they are to be avoided unless you have a specific need for one. The fact that your own array is in a Variant will significantly slow things down when the rest of your code deals with it. You would be far better off using a standard dynamic String array, which you can do simply by changing the declaration to:

Dim aList() as String

Mike


.



Relevant Pages

  • Re: Split Function Creates Error 13 Type Mismatch
    ... A Variant can hold a string and an array of string. ... Dim vAs Variant ... As it is, was Variant accept an array of string returned by Array, but not by Split. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Grouping shapes in Word
    ... The reason that it expects a Variant array as opposed to a String array is that ... a Variant can hold data of any type. ... Variant array of Shape names (string) or a Variant array of shape index numbers ... Dim avarShape() As Variant ...
    (microsoft.public.office.developer.vba)
  • Re: Sorting a variant array
    ... Dim tempList As Variant ... Dim testerList() As String ... Function sortTesters(rangeName As String) ... column range--but even that ends up as a x-rows by 1 column array. ...
    (microsoft.public.excel.programming)
  • Re: Populate listbox from array
    ... Static dbsAs String isn't required in your case: ... Static MyDeptArray As Variant ... > array. ... >> write a call-back function to populate your listbox. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Paasing an array in OpenArgs
    ... Although the OpenArgs property is a variant, the Access 2003 help file indicates it must contain a string expression. ... I thought a good way to do this would be to create an array with the two date values and pass the array in the openargs argument. ...
    (microsoft.public.access.formscoding)