Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6346621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:03:10+00:00 2026-05-24T21:03:10+00:00

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _ Handles Me.Load, Me.FormClosing

  • 0
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
      Handles Me.Load, Me.FormClosing
        MessageBox.Show("form_load")
End Sub


Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) _
    Handles Me.FormClosing
    MessageBox.Show("form_closing")
End Sub

While closing the form I observed that the Form1_FormClosing method is fired first, and then Form1_Load second.

Why is this order chosen? Why doesn’t Form1_Load get fired/entered first, and then Form1_FormClosing second?

How does .NET choose which method to fire first, of the two that handle the same event?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:03:11+00:00Added an answer on May 24, 2026 at 9:03 pm

    Both method have Handles Me.FormClosing, so both methods are executed when the form is closed. There’s no particular orer they’re executed in.

    When several methods handle the same event, the event calls them in the order they asked to receive events. The compiler has arbitrarily decided that the Form1_FormClosing method comes first. Try adding this code between the the two method and see if it changes again.

    Private Sub Aaa(ByVal sender As Object, ByVal e As FormClosingEventArgs)
        Handles Me.FormClosing
        MsgBox("Aaa")
    End Sub
    

    On a side note, I’m surprised your code compiles as Form.Load has a different signature to Form.FormClosing.


    If you want code to execute in a particular order, only handle the event once and call other methods in order.

    Private Sub Form1_Load(sender As Object, e As EventArgs)
        Handles Me.Load
        ReportLoad()
    End Sub
    
    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs)
        Handles Me.FormClosing
        ReportLoad()
        MsgBox("Form1_FormClosing")
    End Sub
    
    Private Sub ReportLoad()
        MsgBox("ReportLoad")
    End Sub
    

    Handling an event in a method of a different name is misleading and confusing. I’d never have guessed that Form1_Load would be called by the FormClosing event. If you want to handle several events, or the same event of several objects, in one method, change the method name, like Form1_xxx or xxxButton_Click so that it’s clear that multiple events are being handled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress Dim allowedChars
I added FileSystemWatcher in Form1_Load like this: Private Sub Form1_Load(ByVal sender As System.Object, ByVal
I have a simple application: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
this doesn't feel right Private Sub drop_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
i have the following code Private Sub select_color_Click(ByVal sender As System.Object, ByVal e As
In my form3 i have this code Private Sub Form3_Load(ByVal sender As System.Object, ByVal
Imports SpeechLib Public Class Form1 Public vox = CreateObject(sapi.spvoice) Private Sub cmdSpeak_Click(ByVal sender As
Hers the form code: Imports TechSupportData Public Class frmOpenIncidents Private Sub frmOpenIncidents_Load(ByVal sender As
really weird behavior in Vb.net 2010 Express. Here is the code: Private Sub Form1_Load(ByVal
I have the following code: Private Sub SortWorksheet(ByVal sheet As Worksheet) Dim sStartColumn Dim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.