From: Alastair MacFarlane on
Dear All,

Please help with the Ubound subscript error I am receiving. I get an error
on the line:

ReDim PRESERVE arrFileType(2, UBOUND(arrFileType, 2) +1 )

This code is heavily abbreviated but the flow is still shown. I am confused
and I would like someone to put me out of my misery.

Thanks again.

Alastair MacFarlane
Scotland

' Fill Array
'=========================================
Dim arrFileType () 'Range of File Types in a folder
Redim arrFileType (2, 0)

Sub ShowSubFolders(Folder,r)
r = r+1
ShowSubFolders Subfolder, r
End Sub

' FILE LOOPING ROUTINE
'==========================================

Function ShowFileList(Subfolder)
FillFileArray f1.name, f1.type, f1.size
End Function

' Create File Array
'===================================
Sub FillFileArray (filename, filetype, filesize)
ReDim PRESERVE arrFileType(2, UBOUND(arrFileType, 2) +1 )
End sub
From: "Dave "Crash" Dummy" on
Alastair MacFarlane wrote:
> Dear All,
>
> Please help with the Ubound subscript error I am receiving. I get an
> error on the line:
>
> ReDim PRESERVE arrFileType(2, UBOUND(arrFileType, 2) +1 )
>
> This code is heavily abbreviated but the flow is still shown. I am
> confused and I would like someone to put me out of my misery.
>
> Thanks again.

Your abbreviated code is unworkable. Need something that actually runs
and shows the error. A simple loop with the redim line works fine.

Dim arrFileType () 'Range of File Types in a folder
Redim arrFileType (2, 0)

for n=0 to 9
ReDim PRESERVE arrFileType(2, UBOUND(arrFileType, 2) +1 )
next

--
Crash

"The real question is not whether machines think but whether men do."
~ B. F. Skinner ~
From: Alastair MacFarlane on
Dave,

Sorry it has taken so long to thank you for your reply. I am still confused
as to why this line does not work.

From your reply do you mean go through a range of possible Ubound values
until one is not returning an error? Handle the errors and continue the loop.

Thanks again.

Alastair

"Dave "Crash" Dummy" wrote:

> Alastair MacFarlane wrote:
> > Dear All,
> >
> > Please help with the Ubound subscript error I am receiving. I get an
> > error on the line:
> >
> > ReDim PRESERVE arrFileType(2, UBOUND(arrFileType, 2) +1 )
> >
> > This code is heavily abbreviated but the flow is still shown. I am
> > confused and I would like someone to put me out of my misery.
> >
> > Thanks again.
>
> Your abbreviated code is unworkable. Need something that actually runs
> and shows the error. A simple loop with the redim line works fine.
>
> Dim arrFileType () 'Range of File Types in a folder
> Redim arrFileType (2, 0)
>
> for n=0 to 9
> ReDim PRESERVE arrFileType(2, UBOUND(arrFileType, 2) +1 )
> next
>
> --
> Crash
>
> "The real question is not whether machines think but whether men do."
> ~ B. F. Skinner ~
> .
>
From: "Dave "Crash" Dummy" on
Alastair MacFarlane wrote:
> Dave,
>
> Sorry it has taken so long to thank you for your reply. I am still
> confused as to why this line does not work.
>
> From your reply do you mean go through a range of possible Ubound
> values until one is not returning an error? Handle the errors and
> continue the loop.

No. I mean post a sample script that actually runs and fails because of
that error. The script you posted does not run, so it is impossible to
see what could be causing the error. As shown in my code snippet, the
function in a normal loop works fine.
--
Crash

"The fewer the facts, the stronger the opinion."
~ Arnold H. Glasow ~