473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Detect Uninitialized / Empty Array using .Net framework?

I have the following bit of code:

j2 = 0
If srvSC(j1) = "XCP CD Proxy" Then
ReDim Preserve badGuys(j2)
badGuys(j2) = j1
j2 += 1
End If

Using .net methods, how can I detect if the badGuys array was never
initialized - even zero times? It throws an exception when I try to do
any kind of test for badguys(0) if it hasn't been given a value!

Nov 28 '05 #1
4 2382
If badGuys.Length = 0 Then

End If

Nov 28 '05 #2
Yes, I tried that - it gives me the following exception: "An unhandled
exception of type 'System.NullReferenceException' occurred in
RootKitDetector.exe"

Additional information: Object reference not set to an instance of an
object.

Any other ideas?

Nov 28 '05 #3
If not badGuys is nothing Then
If badGuys.Length = 0 Then
REM No items in array.
End If
Else
REM No reference, badGuys.Length will throw an exception.
End If
"Bmack500" <br********@gmail.com> schreef in bericht
news:11*********************@g43g2000cwa.googlegro ups.com...
Yes, I tried that - it gives me the following exception: "An unhandled
exception of type 'System.NullReferenceException' occurred in
RootKitDetector.exe"

Additional information: Object reference not set to an instance of an
object.

Any other ideas?

Nov 28 '05 #4
I'm sorry, I should have thought of that. You can use this:

If (badGuys Is Nothing) OrElse badGuys.Length = 0 Then
'Array is not initialized
End If

Nov 28 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: vega | last post by:
How do I detect empty tags if I have the DOM document? For example: <br /> and <br></br> I tried org.w3c.dom.Node.getFirstChild(), it returns null for both <br /> and <br></br> I also tried...
23
by: Michel Bany | last post by:
I am trying to parse responseXML from an HTTP request. var doc = request.responseXML; var elements = doc.getElementsByTagName("*"); the last statement returns an empty collection when running from...
3
by: julien | last post by:
Hello, Is it possible if a boolean was initialized or not? For other types of variable, I usually check if it is null. But this not possible for a boolean. Thank you Julien
7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
4
by: chinu | last post by:
HI all, i am declaring an array in javascript var a = new array(); now before assigning a value to the ith element of this array, i have to check if some value has already been assigned there....
7
by: Tom van Stiphout | last post by:
I want to indicate requiredness by setting the background color of the control. Ideally I would call a sub in Form_Load to just do its thing. Below is what I have so far, but I realize this is of...
2
by: pnsreee | last post by:
Hi All, I have the following code. The array @sub_data will contain integers or a string"NO". I have to validate if the array contain integer. If it contain "NO" then no need to validate. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.