PROKA Posted April 21, 2004 Posted April 21, 2004 Here is my code : Public Class Operatie Public Function Add(ByVal ParamArray x() As Integer) As Integer Dim i As Integer Dim sum As Integer = 0 For Each i In x sum += i Next Return sum End Function End Class Dim proka As Operatie Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click MessageBox.Show(proka.Add(2, 3).ToString) End Sub and here is my error when I click that button :An unhandled exception of type 'System.NullReferenceException' occurred in Learn VB.NET 2.0 Class 3.exe Additional information: Object reference not set to an instance of an object. Quote Development & Research Department @ Elven Soft
*Experts* Nerseus Posted April 22, 2004 *Experts* Posted April 22, 2004 Or make function Add "Shared" and then call it with: MessageBox.Show(Operatie.Add(2, 3).ToString) -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Arch4ngel Posted April 22, 2004 Posted April 22, 2004 Your error is caused by this : Operatie value is NULL. And you can't reference .Add of an null object ya ? Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
PROKA Posted April 22, 2004 Author Posted April 22, 2004 Thanks Guys Quote Development & Research Department @ Elven Soft
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.