Re: How do I? (2 Questions)
Question 1:
dunno
Question 2:
You can call the element, and watch for errors, like this:
on error resume next ' ignore errors
Err.Clear ' clear previous errors (if any)
x = Ubound(myArray)
on error Goto 0 ' no longer ignoring errors
If Err.Number <> 0 then
' no elements
else
' at least 1 element
End If
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
Re: How do I? (2 Questions)
Q2:
No the "on error resume" method is the only way I have found to test arrays which is why they are unsafe.
I have taken to always using objects of type "Collection" instead and have written this requirement into my co. VB coding standards.
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Re: How do I? (2 Questions)
Another option is to have another function to check for the upperbound of the array:
function AnyElement(myArray() as string) as Boolean
on error trap_err
call ubound(myArray)
AnyElement = true
exit function
trap_err:
AnyElement = false
end function
Good luck.
-Cool Bizs
Re: How do I? (2 Questions) - for Q1
Forgot about the Q#1. Hmm... well you have to resort to using APIs. Few functions that you can check out: GetDiskFreeSpaceEx() or a combination of CreateFile() and DeviceIoControl() functions.
I've written a little COM DLL that gets the size of the disk (total and free space). Email me if you wanna check it out.
-Cool Bizs
Re: How do I? (2 Questions)
Thanks to all of you that responded to my plea. On Question #1 (Disk CLuster size) - GetDiskFreeSpace does give Cluster Size but is limited to disks < 2.x Gigabytes. GetFreeSpace.EX and GetFreeSpaceEXAsCurrency provide support for disks > 2.0 Gig but does not include the Cluster size.
The GetDiskFreeSize does appear to work correctly for Clusters. Just the Space reporting is incorrect. I may just look into IODEVICECONTROl as per one of the suggestions.
Again, Thanks
John G