6

I just can't, im guessing something's not enabled, but what?

enter image description here

1
  • 1
    How did you create the ApplicationEvents.vb file? Did you use the button on the project properties dialog?
    – JohnFx
    Dec 3, 2011 at 1:19

2 Answers 2

6

Go to your "My Project" node in your solutions tree. Click on this button:

enter image description here

It should result in the following file:

Namespace My

  ' The following events are available for MyApplication:
  ' 
  ' Startup: Raised when the application starts, before the startup form is created.
  ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
  ' UnhandledException: Raised if the application encounters an unhandled exception.
  ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
  ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
  Partial Friend Class MyApplication

  End Class

End Namespace

Once there, you should have the (MyApplication Events) in the left ComboBox in your code editor, and the list of events in the right ComboBox.

Note: You might have to delete the empty file you already have before creating this.

1

I think the problem here is that you simply created a .vb file without relating it to something that actually has events. Based on the picture, I'm thinking you want to handle the events in your frmInvoice.vb in the ApplicationEvents.vb. If this is the intent, then you should preface the class definition in the frmInvoice file with Partial and create an identically named class in the ApplicationEvents.vb (also prefaced with partial). The partial keyword allows you to span classes across files. The implementation looks like this:

'On actual form
    Partial Public Class Form1

    End Class

'On other .vb file
    Partial Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            MsgBox("test")
        End Sub
    End Class

I personally don't care for this approach and prefer using regions within a single file.

#region "Events"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.