Question:

Is there a way to put codes in the close button of a form in visual basic?

by  |  earlier

0 LIKES UnLike

what i mean is the control menu the minimize, maximize and the x one is the close

 Tags:

   Report

3 ANSWERS


  1. Yes,  explore the Button_Click event.

    Private Sub Button_Click(sender As Object, e As EventArgs)

    ' Do something useful

    End Sub


  2. Use the FormClosed event (VB.Net) or Unload event (VB6) and put what ever code you need there.

    Good luck!

    Edited to add:

    This event is triggered when the form is closed by whatever means you use ... especially the "X" in the upper right corner.

  3. How about doing it the easy way...

    Just add them in the Properties pane at design time.

    No code required!!

    Or:

    In VB2008 its called the MinimizeBox and is located in the Properties Pane. In VB6 its called the MinButton and it is also located in the Properties Pane.

    A Minimize button enables users to minimize a form window to an icon. To display a Minimize button, you must also set the form's BorderStyle property to either 1 (Fixed Single), 2 (Sizable), or 3 (Fixed Double).

    VB6:

    Form1.MinButton = True or False

    True = (Default) The form has a Minimize button.

    False = The form doesn't have a Minimize button.

    The settings you specify for the MaxButton, MinButton, BorderStyle, and ControlBox properties aren't reflected in the form's appearance until run time.

    VB2008:

    Me.MinimizeBox = True

    Me.MinimizeBox = False

    Get the idea!!

    : )

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions