|
-
Jul 1st, 2004, 12:46 PM
#1
Thread Starter
Addicted Member
Instance of an object
I am getting an "Object reference not set to an instance of an object" error on this code. I have searched the forums, but I cannot seem to find an example that is helping me. I am used to VB6, and trying to understand the basics of .NET
This is in a module, and there is a label on the frmMain called lblTestOutput
VB Code:
Public Sub MakeChanges()
Dim f As New frmMain
If f.lblTestOutput.Text = "" Then
f.lblTestOutput.Text = "Button Pushed!"
Else
f.lblTestOutput.Text = ""
End If
End Sub
Also, I am wondering...
what is the correct way to load up a form using "Sub Main?"
BeengieHappy.Vaue = (SharksScore > OpponentsScore)
Go Sharks!
-
Jul 1st, 2004, 01:08 PM
#2
When you started that project, what kind of project did you choose?
I have tried your code and it worked without error, although the app exits almost immediately after it starts (as predicted).
I don't live here any more.
-
Jul 1st, 2004, 01:11 PM
#3
Thread Starter
Addicted Member
I chose a "Windows Application"
BeengieHappy.Vaue = (SharksScore > OpponentsScore)
Go Sharks!
-
Jul 1st, 2004, 01:37 PM
#4
Thread Starter
Addicted Member
I added "f.Show" to the code
VB Code:
Option Explicit On
Option Strict Off
Module mdlTesting
Private f As New frmMain
' Public Sub Main()
' Dim g As frmMain
' Application.Run(g)
' End Sub
Public Sub MakeChanges()
If f.lblTestOutput.Text = "" Then
f.lblTestOutput.Text = "Button Pushed!"
Else
f.lblTestOutput.Text = ""
End If
Console.WriteLine(f.lblTestOutput.Text)
f.Show()
End Sub
End Module
to the module, and now it shows up.
But...
Now I have two forms open now because I had to dimension "f" as "New".
Isn't there a way to reference it without it being "New?"
Or what do I need to do to correct this?
Last edited by Beengie; Jul 1st, 2004 at 03:10 PM.
BeengieHappy.Vaue = (SharksScore > OpponentsScore)
Go Sharks!
-
Jul 1st, 2004, 05:06 PM
#5
PowerPoster
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
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
|