Bouton 2 fonctions

Bonjour,

Voila j'ai formulaire avec un bouton pour agrandi sur la largeur mon formulaire avec se code

Private Sub CommandButton1_Click()
Me.Width = 440
End Sub

Et j’aimerai avec le même bouton revenir à la largeur initial

Je vous remercie d'avance

Max

Bonjour,

Private Sub CommandButton1_Click()
    If Me.Width = 240 Then
        Me.Width = 440
    Else
        Me.Width = 240
    End If
End Sub

A+

Bonsoir

Je te remercie ton code marche nickel.

J'ai essayer de lui apporter une petite modi sans succès en lui mettant le code suivant

    Private Sub CommandButton1_Click()
        If Me.Width = 240 Then: Me.CommandButton1.Caption = "Ouvrir"
            Me.Width = 440
        Else
            Me.Width = 240: Me.CommandButton1.Caption = "Fermer"
        End If
    End Sub

Pour que le bouton donne deux messages

Pourrez tu me dire ou est l'erreur de façon a ne plus commettre la même erreur

Merci d'avance

@+

Max


Re,

Peut être j'ai trouvé je le met mon code ici:

Sub userform_initialize()
CommandButton1.Caption = "Ouvrir"
End Sub

Private Sub CommandButton1_Click()
If CommandButton1.Caption = "Ouvrir" Then
    CommandButton1.Caption = "Fermer" '''''
     Me.Width = 240
            Me.Width = 440
ElseIf CommandButton1.Caption = "Fermer" Then ''''''''''''
    CommandButton1.Caption = "Ouvrir"
     Me.Width = 240
End If
End Sub

Voila @+

Max

Re,

Sub userform_initialize()
    Me.Width = 240
    CommandButton1.Caption = "Ouvrir"
End Sub
Private Sub CommandButton1_Click()
    If CommandButton1.Caption = "Ouvrir" Then
        CommandButton1.Caption = "Fermer" '''''
        Me.Width = 440
    ElseIf CommandButton1.Caption = "Fermer" Then ''''''''''''
        CommandButton1.Caption = "Ouvrir"
        Me.Width = 240
    End If
End Sub

A+

Rechercher des sujets similaires à "bouton fonctions"