(ByVal sender As Object, ByVal e As EventArgs) explanation

Posted on 2011-04-19
Last Modified: 2012-05-11
Could someone explain the below line of code in real simple terms for me (very new to VB)....

(ByVal sender As Object, ByVal e As EventArgs)

Question by:deanlee17
    LVL 53

    Accepted Solution

    ByVal means it is passing the variable by value.

    sender is an object of generic type System.Object.     All objects in .NET inheirit from System.Object, as such it is passing the control that is causing the event to fire.

    e is an object of type System.EventArgs where EventArgs is the generic Class for event arguments or, the arguments the event is passed.


    For example, if you turn your button into an ImageButton, by changing <asp:Button ....> into <asp:ImageButton...> but leave everything else the same, the compliation will fail, because ImageButton requires different Event ARguments because it passes those arguments to the event handler.  An imagebutton event handler would be:

    Protected Sub ImageButton2_Click(ByVal sender As System.Object, ByVal e As ImageClickEventArgs) Handles ImageButton2_Click


    LVL 16

    Assisted Solution

    by:Imran Javed Zia
    you generally find this libne with event handler  (ByVal sender As Object, ByVal e As EventArgs)

    here sender is object which is creating the event so if ytou have this event for some textbox then you can use it as textbox as and so on

    on the other hand e is the event argument and it carries the event information

    you can find details on following links:


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now