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

Adding a objet to a queue

I am trying to create a queue of objects. I have a taskHolder object using a
Task class. I have an activeproject object of project class. Each project has
a queue called Tasks.
Everything looks good up to the point that i try to add the taskholder
object to the queue. I get an nullreferenceexception, indicating that
Me.taskholder is not defined. I even added a NULL test and I get a "wooo!"
every time. Even in the debugger I can see the values in taskholder while it
is saying it does not exist.
What am I doing wrong here?

Private Sub WereDone()
'we are done with this form and will now begin the output process
Dim row As Integer

taskHolder.Reset()
row = (Me.ActiveTask.Index - 2)
For count As Integer = 0 To row Step 1
taskHolder.Index = Me.TasksDataGridView1.Item(0, count).Value
taskHolder.Name = Me.TasksDataGridView1.Item(1, count).Value
taskHolder.TaskDuration = Me.TasksDataGridView1.Item(2,
count).Value
taskHolder.Pred.Add(1, (Me.TasksDataGridView1.Item(3,
count).Value))
taskHolder.BM = Me.TasksDataGridView1.Item(4, count).Value
taskHolder.TW = Me.TasksDataGridView1.Item(5, count).Value
If taskHolder Is Nothing Then
MsgBox("oh crap!")
Else
MsgBox("wooo!")
End If
StartForm.ActiveProject.Tasks.Enqueue(Me.taskHolde r) <---- Here!
taskHolder.Reset()
Next
MsgBox(StartForm.ActiveProject.Tasks.Count)

End Sub
Thanks!
Aug 29 '07 #1
3 1481
I just tried doing things the correct way, making tenqueue and tdequeue
methods in the project class and using them instead of accesing the queue
directly.
but I still got the same result. If i hover my mouse over the T, I can see
the data.

Public Sub TEnqeue(ByVal T As Task)
Tasks.Enqueue(T) <----exception!
End Sub

"A Shawn" wrote:
I am trying to create a queue of objects. I have a taskHolder object using a
Task class. I have an activeproject object of project class. Each project has
a queue called Tasks.
Everything looks good up to the point that i try to add the taskholder
object to the queue. I get an nullreferenceexception, indicating that
Me.taskholder is not defined. I even added a NULL test and I get a "wooo!"
every time. Even in the debugger I can see the values in taskholder while it
is saying it does not exist.
What am I doing wrong here?

Private Sub WereDone()
'we are done with this form and will now begin the output process
Dim row As Integer

taskHolder.Reset()
row = (Me.ActiveTask.Index - 2)
For count As Integer = 0 To row Step 1
taskHolder.Index = Me.TasksDataGridView1.Item(0, count).Value
taskHolder.Name = Me.TasksDataGridView1.Item(1, count).Value
taskHolder.TaskDuration = Me.TasksDataGridView1.Item(2,
count).Value
taskHolder.Pred.Add(1, (Me.TasksDataGridView1.Item(3,
count).Value))
taskHolder.BM = Me.TasksDataGridView1.Item(4, count).Value
taskHolder.TW = Me.TasksDataGridView1.Item(5, count).Value
If taskHolder Is Nothing Then
MsgBox("oh crap!")
Else
MsgBox("wooo!")
End If
StartForm.ActiveProject.Tasks.Enqueue(Me.taskHolde r) <---- Here!
taskHolder.Reset()
Next
MsgBox(StartForm.ActiveProject.Tasks.Count)

End Sub
Thanks!
Aug 29 '07 #2
RB
A Shawn wrote:
I just tried doing things the correct way, making tenqueue and tdequeue
methods in the project class and using them instead of accesing the queue
directly.
but I still got the same result. If i hover my mouse over the T, I can see
the data.

Public Sub TEnqeue(ByVal T As Task)
Tasks.Enqueue(T) <----exception!
End Sub
--SNIP--

Presumably you've checked that your Tasks object has been/is still
instantiated? Sorry to sound dopey, but it's all I can think of!!!

Also, can you confirm that the exception is being thrown at the line

Tasks.Enqueue(T)

and not from a line inside the Enqueue function?

Cheers,

RB.
Aug 30 '07 #3
Ok, I found it. In my project class i had:
Public Tasks As Queue
insetad of:
Public Tasks As New Queue

I was thinking the problem was with the object I was trying to put in the
queue instead of the queue itself. Duh.

"RB" wrote:
A Shawn wrote:
I just tried doing things the correct way, making tenqueue and tdequeue
methods in the project class and using them instead of accesing the queue
directly.
but I still got the same result. If i hover my mouse over the T, I can see
the data.

Public Sub TEnqeue(ByVal T As Task)
Tasks.Enqueue(T) <----exception!
End Sub
--SNIP--

Presumably you've checked that your Tasks object has been/is still
instantiated? Sorry to sound dopey, but it's all I can think of!!!

Also, can you confirm that the exception is being thrown at the line

Tasks.Enqueue(T)

and not from a line inside the Enqueue function?

Cheers,

RB.
Aug 30 '07 #4

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

Similar topics

9
by: phil | last post by:
And sorry I got ticked, frustrating week >And I could help more, being fairly experienced with >threading issues and race conditions and such, but >as I tried to indicate in the first place,...
9
by: Brian Henry | last post by:
If i inherite a queue class into my class, and do an override of the enqueue member, how would i then go about actually doing an enqueue of an item? I am a little confused on this one... does over...
3
by: Kceiw | last post by:
Dear all, When I use #include "queue.h", I can't link it. The error message follows: Linking... G:\Projects\Datastructure\Queue\Debug\main.o(.text+0x136): In function `main':...
5
Rooro
by: Rooro | last post by:
Hello everyone i'm working on : " Familiar childhood games such as hide and Go Seek and Tag involve determining the player who is to be "It". One method has the players stand in a circle...
2
by: lavender | last post by:
When define a maxQueue is 10, means it able to store 10 items in circular queue,but when I key in the 10 items, it show "Queue Full" in items number 10. Where is the wrong in my code? Why it cannot...
3
by: jrpfinch | last post by:
I have a script which is based on the following code. Unfortunately, it only works on Python 2.3 and not 2.5 because there is no esema or fsema attribute in the 2.5 Queue. I am hunting through...
4
by: j_depp_99 | last post by:
Thanks to those guys who helped me out yesterday. I have one more problem; my print function for the queue program doesnt work and goes into an endless loop. Also I am unable to calculate the...
2
by: ecestd | last post by:
how do you implement a copy constructor for this pointer-based ADT queue #include <cassert // for assert #include <new // for bad_alloc using namespace std; //private:{Queue::Queue(const...
0
by: ecestd | last post by:
I did implement the copy constructor but still have a problem with it. It is not working. What could be wrong? #include "QueueP.h" #include <cassert // for assert #include <new // for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.