Resize Event
Applies To
UserForm object.
Description
Occurs when a user form is resized.
Syntax
Private Sub UserForm_Resize( )
Remarks
Use a Resize event procedure to move or resize controls when the parent UserForm is resized. You can also use this event procedure to recalculate variables or properties.
Example
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
Else
' 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