473,396 Members | 1,724 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,396 software developers and data experts.

Object reference not set to an instance of an object Question

Expand|Select|Wrap|Line Numbers
  1. Dim AircraftInfo As New Aircraft
  2. AircraftInfo = mAircraft.AddAircraft(txtCraftID.Text)
&

Expand|Select|Wrap|Line Numbers
  1.  Private mCraft() As Aircraft
  2.         Private mintAircraftCount As Integer
  3.  
  4.         Public Function AddAircraft(ByVal mAircraftID As String, ByVal mArrivalTime As DateTime) As Aircraft
  5.             mCraft(mintAircraftCount).AircraftID = mAircraftID
  6.             mCraft(mintAircraftCount).ArrivalTime = mArrivalTime
  7.             mintAircraftCount += 1
  8.             Return mCraft(mintAircraftCount - 1)
  9.         End Function
  10.  
  11.  
These bits of code keep giving me a "Object reference not set to an instance of an object" Error at mCraft(mintAircraftCount).AircraftID = mAircraftID everytime I try to run the function.

What am I doing wrong?

Cheers!
Jul 14 '07 #1
1 951
Killer42
8,435 Expert 8TB
It looks to me as though array mCraft never had any occurrences created. I think you need a ReDim there somewhere. Probably with the Preserve keyword, to avoid zapping any existing occurrences.
Jul 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Edward Diener | last post by:
This simple code example gives me the message, "TypeError: 'staticmethod' object is not callable". class X(object): def Y(x): print x Y = staticmethod(Y) ad = { 1 : Y } def Z(self):...
2
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server...
1
by: WONG Chi Kit Keith | last post by:
When the following script is processed, errors return: Partial Class _Default Inherits System.Web.UI.Page Public Sub New() Me.txtBox.Text = "This is a text box." End Sub End Class
0
by: cnSoftware | last post by:
I come across this problem during my recent project and even now I am still be puzzled by it. So I paste the procedure here. I wish you can figure out where I am wrong or missing. The sample...
15
by: Sam Kong | last post by:
Hello! I got recently intrigued with JavaScript's prototype-based object-orientation. However, I still don't understand the mechanism clearly. What's the difference between the following...
2
by: Ivor Somerset | last post by:
Hello, In my ASP code I sometimes write functions that return an object (generally an XML node). Such a function is invoked this way: Set Object1 = MyFunction(SomeValue) And at the end of...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
32
by: Joe | last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing quite often the following (this example taken from a wiki): $wakka =& new Wakka($wakkaConfig); What exactly is the =&, and...
4
by: Dominik Gallus | last post by:
Hey there, What i know is that a delegate is a (address)reference to a method or a object-instance's method. But how can i have a reference JUST to a object instance? Is this also done by...
45
by: =?Utf-8?B?QmV0aA==?= | last post by:
Hello. I'm trying to find another way to share an instance of an object with other classes. I started by passing the instance to the other class's constructor, like this: Friend Class...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.