Computing.Net > Forums > Programming > Vb.net

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Vb.net

Reply to Message Icon

Name: Val
Date: October 23, 2002 at 10:17:57 Pacific
OS: windows 2000
CPU/Ram: don't know
Comment:

Does anybody know how to check in VB.NET if array is empty?
Thank you




Sponsored Link
Ads by Google

Response Number 1
Name: Jeff J
Date: October 23, 2002 at 12:09:49 Pacific
Reply:

By empty, I assume you are refering to a VB5/6 Variant type, which could "hold" an array. If an array (or anything else) was not assigned to a Variant, one could use the IsEmpty() function on the Variant, to see if it refered to an array. Arrays themselves cannot be checked for emptiness, since if they exist, they never are.

VB.Net does still provide the Object type, which is an enhanced version of the VB5/6 Object type. They completely replace the Variant type, and can be checked as before by seeing if they refer to Nothing (null pointer in C/C++ terms):

Dim oVar As Object
' do stuff with object,
' such as Set oVar = MyArray

If oVar Is Nothing Then '...

FWIW, it's probably best that the concept of being "empty" has been dropped, since it is misleading and not used by most other languages anyway. As it is, the keyword "Nothing" in VB becomes the keyword null/NULL in most other popular languages.

Cheers


0
Reply to Message Icon

Related Posts

See More


DoCmd.SendObject acQuery, Break a loop



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Vb.net

How do I hide a form on load vb.net www.computing.net/answers/programming/how-do-i-hide-a-form-on-load-vbnet/4597.html

Vb .net www.computing.net/answers/programming/vb-net/13338.html

VB.net get previous date www.computing.net/answers/programming/vbnet-get-previous-date/14687.html