|
-
Apr 8th, 2004, 07:52 AM
#1
Thread Starter
Frenzied Member
problem referencing a form
ok, I followed the direction for mimicking a global form from here:
http://msdn.microsoft.com/library/de...adingToNET.asp
I have followed the instructions to a 'T'. I created a Sub Main() in my module for my functions. I set the startup object to load sub main first.
in the sub main, I placed the code to instantiate the class just like the page said.
I get an error: object reference not set to an instance of an object
whn trying to manipulate a listview my calling it this way:
MainForm.Ticketing.tab_TrblHistory_lvwTroubleHistory.Items.Add(History(intCount).TicketNumber)
MainForm is the class, ticketing is the property and rest is the control I'm trying to add a row to.
What am I missing here?
Last edited by Andy; Apr 8th, 2004 at 11:08 AM.
-
Apr 8th, 2004, 12:13 PM
#2
Hyperactive Member
Dear Ninja, might you insert the code that declare and instance the form?
It should be like this, I assume:
Public FrmReg As New FrmRegistrazioni
If it's so and if your program step trough this code (put a break and verify) you should not have any problem.
Waiting for your news.....
Live long and prosper (Mr. Spock)
-
Apr 8th, 2004, 12:16 PM
#3
Hyperactive Member
Excuse me, Andy, I confused your nick!!!
I have seen another thread just few seconds before and my memory failed!
Live long and prosper (Mr. Spock)
-
Apr 8th, 2004, 12:50 PM
#4
Thread Starter
Frenzied Member
ninja IS a cool nickname!!
VB Code:
Sub main()
Dim MainApp As New frmTicketingMain
MainApp.Showdialog()
MainForm.Ticketing = MainApp
End Sub
That is where my program enters and "MainApp" is supposed to be the only form visible.
frm TicketingMain is the actual form that I created and it is the application. MainForm is the class and ticketing is the property. here is the class and property:
VB Code:
Public Class MainForm
'Purpose : sets up a "global" instance of the application
'Accepts :
'Returns :
'Notes :
Private Shared m_MainForm As frmTicketingMain
Public Shared Property Ticketing() As frmTicketingMain
Get
Return m_MainForm
End Get
Set(ByVal Value As frmTicketingMain)
m_MainForm = Value
End Set
End Property
End Class
here is where I get the error:
VB Code:
MainForm.Ticketing.ListView1.Items.Add(Object1(intCount).ItsProperty)
I gave the names as you see them for clarity. 
I have tried other things with that last statement such as writing to a text box on mainForm.ticketing or simply writing something to the console. I still get that error.
-
Apr 8th, 2004, 01:02 PM
#5
Thread Starter
Frenzied Member
hmm...I have discovered this: the property "Ticketing" is equal to Nothing. That's weird cause it IS equal to the frmTicketingMain UNTIL it gets to the location I pointed out (thelistview).
what could be causing the object to lose it's property value?
-
Apr 8th, 2004, 02:28 PM
#6
Frenzied Member
Declare MainApp outside of Sub Main, like a form level module. Declare it as Public if you plan on referencing it from any form outside your module.
-
Apr 8th, 2004, 02:34 PM
#7
Thread Starter
Frenzied Member
ok. so I Won't need sub Main then, right? that's where the program gets fired off. If I declare it outside, I'll have declared it twice: once to show the form inside form main and then once again outside.
I guess I could have the startup object as the main form? will that still work?
-
Apr 8th, 2004, 03:41 PM
#8
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|