HOME       >>       Programming

[visual Basic] How To Confirm A Array Is Null


jedipi

for example,Dim array() as integerduring run time, how to confirm a array is null (do not contain any element)Thanks


szupie

Uh... Are you asking a question or is this like a tutorial? If it is a question, please use the "How do I confirm" or "How is an array confirmed" form, or simply add a question mark. I'm not trying to mock you...


BabyTux

on error goto wDim a() As IntegerDim i As Integeri = UBound(a)    'If a() contains no element an error will occurexit subw:    msgbox "Array is empty!"

jipman

Euh... how about this:dim a() as integerif lbound(a) = ubound(a) and lbound(0) = 0 then msgbox "aray is empty"


vizskywalker

If the array is completely empty and thus null, you could just use the IsNull function, like so or IsEmpty():If Isnull(array) then msgbox "array is empty"orIf IsEmpty(array) then msgbox "array is empty"


jedipi

If the array is completely empty and thus null, you could just use the IsNull function, like so or IsEmpty():

If Isnull(array) then msgbox "array is empty"

or

If IsEmpty(array) then msgbox "array is empty"

<{POST_SNAPBACK}>


Thanks for your help.

 

yes..I just use IsEmpty() function to get the task done.


tansqrx

Didn't really see if you were talking VB 6 or .NET. In .NET you can use the "Nothing" keyword.Dim array() As Integer If array Is Nothing Then 'do something End If



VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.