Re: Increment a Variable?

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



"Klatuu" <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5430DB28-D61B-4C29-AA88-E75C38275AF3@xxxxxxxxxxxxx
> No, it does not have to be a Variant type, but you can't change data
> types with a redim unless the array is contained in a Variant.
>
> "Dirk Goldgar" wrote:
>
>> "Klatuu" <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:B8BC07DC-BC5F-4BE6-A2ED-B229075B6C74@xxxxxxxxxxxxx
>>> Or:
>>> Dim MyArray(100) As Variant ' or as a specific type
>>> Dim I As Integer
>>>
>>> Do While <some condition>
>>>
>>> If I >= UBound(MyArray) Then
>>> Redim MyArray(I+1) Preserve
>>> End If
>>> I = I + 1
>>> MyArray(I) = <some value>
>>>
>>> Loop
>>
>> <g> I thought of that, but didn't want to get too deep. I believe,
>> though, that for your version to work, you have to change this:
>>
>>> Dim MyArray(100) As Variant
>>
>> to this:
>>
>> Dim MyArray() As Variant
>>
>> ' ...
>>
>> ReDim MyArray(100) ' maybe a good starting size
>>
>> or just this:
>>
>> ReDim MyArray(100) ' to start with

No, that wasn't my point. My point was that if you declare the array as
non-dynamic (by using Dim with specific bounds), you won't be able to
use ReDim to change the bounds.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.



Relevant Pages

  • Re: Max/Min Functions
    ... You said the Array function won't work here. ... Dim myArray() As Variant ... > Dim vMax As Variant ...
    (microsoft.public.word.vba.general)
  • Re: Calculating Networking days excluding Sundays
    ... Function SelectionSort(TempArray As Variant) ... Dim MaxIndex As Integer ... ' Step through the elements in the array starting with the ... ReDim TempArray2As Variant ...
    (microsoft.public.excel)
  • Re: Max/Min Functions
    ... You can stuff a value of any other data type into a Variant ... > Dim myArrayAs Variant ... > a whole array into a single Variant variable, ... > Dim vMax As Variant ...
    (microsoft.public.word.vba.general)
  • Re: shape range help
    ... However initial use of Dim() avoided use of brackets and he ... Everytime with ReDim only, I get a Variant() ... never in a session I don't do the initial Dim varr() then redim does NOT ...
    (microsoft.public.excel.programming)
  • Re: Weekending Saturday
    ... Optional Holidays As Variant = Nothing, ... Dim arrayH As Variant, arrayW As Variant ... ' or not an array or cell range with numeric values, ... ReDim arrayH) As Variant ...
    (microsoft.public.excel.worksheet.functions)