Count Length of Array or Textfile

K

Kou Vang

Can I use the count method to get the length of an Array or Textfile? Thanks.

Kou
 
S

Steve Jorgensen

Can I use the count method to get the length of an Array or Textfile? Thanks.

Kou

In VBA, an Array is not an object, so it has no methods, so it has no Count
method. You can get the number of elemnts in a 1-dimensional array using
UBound(<array>) - LBound(<array>) + 1.

A file is a bunch of bytes on a drive. If you create an object that
references the file using something like FSO, I think there is some sort of
Length method you can use to get the length of the file in bytes/characters.
You can use Windows API calls to check a file's length as well.
 
M

Martin Seelhofer

Hi there
In VBA, an Array is not an object, so it has no methods, so it has no
Count
method. You can get the number of elemnts in a 1-dimensional array using
UBound(<array>) - LBound(<array>) + 1.

A file is a bunch of bytes on a drive. If you create an object that
references the file using something like FSO, I think there is some sort
of
Length method you can use to get the length of the file in
bytes/characters.
You can use Windows API calls to check a file's length as well.

.... or use the FileLen(...)-function ;-)


Cheers,
Martin
 
K

Kou Vang

Thanks! I think it worked. I used the Filelen to redim an array, that way
I'm not always guessing how large to make it.

Kou
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top