in a module have a public variable mio_array() as string
now i fill the array with:
...
AR=0
for i to ...
ReDim Preserve MIO_ARRAY(AR) As String
MIO_ARRAY(AR) = RS.Fields(0).Value & "-" & ITMX.SubItems(5)
AR = AR + 1
next i
...
is rquired to dim mio_array, or the statement ReDim Preserve MIO_ARRAY(AR) As String, dim the variable?
REDIM PRESERVE array
-
- Administrator
- Posts: 78238
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: REDIM PRESERVE array
You need both:
- You cannot use ReDim Preserve if you haven't declared the array before that.
- In Redim Preserve, you must specify the new upper bound (AR).
- You cannot use ReDim Preserve if you haven't declared the array before that.
- In Redim Preserve, you must specify the new upper bound (AR).
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4334
- Joined: 26 Apr 2010, 17:36
Re: REDIM PRESERVE array
ok
now i find in array with:
If InStr(Join(MIO_ARRAY), RS.Fields(0).Value) > 0 Then
STATO = "?"
End If
now ho to fill STATO with the element of array?
the array is similar
72-aaa
80-bbb
...
986-ccc
in this case RS.Fields(0).Value=72
i need STATO = "72-aaa"
other way are welcome
note:
not possible duplicates in array
-
- Administrator
- Posts: 78238
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: REDIM PRESERVE array
I'd use this:
Code: Select all
Dim MIO_ARRAY2
MIO_ARRAY2 = Filter(MIO_ARRAY, RS.Fields(0).Value)
If UBound(MIO_ARRAY2) >= 0 Then
STATO = MIO_ARRAY2(0)
End If
Best wishes,
Hans
Hans