Re: Increment a Variable?



"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

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

(please reply to the newsgroup)


.



Relevant Pages

  • Re: Array Declaration Problem ??
    ... the declaration ReDim awas commented out in Function Zroots. ... Function ZrootsAs Variant() ... Dim j As Integer, its As Integer ... Enter on a worksheet the function "MyRoots() and select a 4 Row*2 Column ...
    (microsoft.public.excel.programming)
  • Re: Array Declaration Problem ??
    ... Function MyRoots (a As Variant, m As Integer, polish As String) ... Dim Roots As Variant ... ReDim ad ...
    (microsoft.public.excel.programming)
  • Re: Re:workdays
    ... Optional Holidays As Variant = Nothing, ... Dim arrayH As Variant ... ' or not an array or cell range with at least one numeric value between ... ReDim arrayH) As Variant ...
    (microsoft.public.excel)
  • Re: How do I Create ragged arrays in Excel VBA?
    ... Sub RaggedArray() ... Dim AAs Variant, i As Long, j As Long ... As Variant ... ReDim A ...
    (microsoft.public.excel.programming)
  • 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)

Loading