Hi
How can i check to see if an UDT array is nothing?
Thanks
Printable View
Hi
How can i check to see if an UDT array is nothing?
Thanks
Dim lTemp as long
On Error Resume Next
lTemp = LBound(MyUDTArrray)
If Err.Number <> 0 Then
msgbox "MyUDTArray has not been dimensioned!"
end if
On Error Goto 0
Thanks for your reply, but anyone know another way?
Im sure theres a way you can do it like
If UDTarray = nothing or similar
Well, with objects you can do
VB Code:
if theObject is nothing then 'do whatever end if
I'm pretty sure that won't work with UDT's though
Checking for an error in one way or another is the only way it can be done. "Nothing" can only be used with objects.
Arrays are not objects, and therefore can not be compared to nothing...
Think about it, you never do:
Set MyArray = New Array
Do you? so the array IS NOT AN OBJECT.. and will never ever, ever ever ever ever ever ever ever ever ever ever ever ever ever be nothing... :eek:
I assumed when you said nothing in relation to an array you mean that it had not been dimensioned.. This is the closest to nothing an array will ever get. ;)
Thanks for your replies, i understand arrays are not objects, its just that when an array is not dimensioned, vb (in a tooltip) pops up the word 'nothing' when my mouse if hovered over the array, so i just thought maybe you could check it like you could with objects.
Ohwell, the On error will do fine, just i didnt want to do that if there was a simpler way
Thanks
VB Code:
If IsArray([i]MyArray[/i]) Then ...