Table of contents
Collapse the table of content
Expand the table of content

Resize Event

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Occurs when a user form is resized. SyntaxPrivate Sub UserForm_Resize()Remarks Use a Resize event procedure to move or resizecontrols when the parent UserForm is resized. You can also use this event procedure to recalculatevariables orproperties.


The following example uses the Activate and Click events to illustrate triggering of the UserForm's Resize event. As the user clicks the client area of the form, it grows or shrinks and the new height is specified in the title bar. Note that the Tag property is used to store the UserForm's initial height.

' Activate event for UserForm1
Private Sub UserForm_Activate()
    UserForm1.Caption = "Click me to make me taller!"
    Tag = Height    ' Save the initial height.
End Sub

' Click event for UserForm1
Private Sub UserForm_Click()
    Dim NewHeight As Single
    NewHeight = Height
    ' If the form is small, make it tall.
    If NewHeight = Val(Tag) Then
        Height = Val(Tag) * 2
    ' If the form is tall, make it small.
        Height = Val(Tag)
    End If
End Sub

' Resize event for UserForm1
Private Sub UserForm_Resize()
    UserForm1.Caption = "New Height: " &; Height &; "  " &; "Click to resize me!"
End Sub
© 2018 Microsoft