Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

Hi everybody, I have a problem with my project in Visual Basic. When I want to run my simple program I see this message: A first chance exception of type 'System.InvalidOperationException' occurred in Unit 6.exe Additional information: An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. " Everything was working before. But something happened and I have no idea what. Please help me to solve this problem.

OpenStudy (anonymous):

My code is... Public Class Form1 Dim decPrice As Decimal = CDec(txtPrice.Text) Dim intQuantity As Integer = CInt(txtQuantity.Text) Dim decTotal As Decimal = CDec(txtTotal.Text) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click decTotal = decPrice * intQuantity * 1.0925 End Sub Private Sub btnQuit_Click(sender As Object, e As EventArgs) Handles btnQuit.Click Me.Close() End Sub End Class

OpenStudy (e.mccormick):

Well, you have something in there as an object, but rather than pointing to an object it is trying to be assigned a value or a null.

OpenStudy (anonymous):

Thank you. But I can't find anything wrong. Can you see the mistake? Please, point out.

OpenStudy (e.mccormick):

Well, each of the buttons is an object. Did you change any names? Also, there is more to VB code than what you see. The layout editor makes its code elsewhere. Might be some mismatch between them.

OpenStudy (anonymous):

I've just checked but everything is fine. No changes was made. The strange point that before that project worked but something happened (I have no idea what) and it dropped. Please see the project. Thank you Tamara

OpenStudy (anonymous):

it's the different one but the same mistake.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!