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

Zoom Event, Zoom Property, Label Control Example

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

The following example uses the Zoom event to evaluate the new value of the Zoom property and adds scroll bars to the form when appropriate. The example uses a Label to display the current value. The user specifies the size for the form by using the SpinButton and then clicks the CommandButton to set the value in the Zoom property.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • A Label named Label1.

  • A SpinButton named SpinButton1.

  • A CommandButton named CommandButton1.

  • Other controls placed near the edges of the form.

Private Sub CommandButton1_Click() 
 Zoom = SpinButton1.Value 
End Sub 

Private Sub SpinButton1_SpinDown() 
 Label1.Caption = SpinButton1.Value 
End Sub 

Private Sub SpinButton1_SpinUp() 
 Label1.Caption = SpinButton1.Value 
End Sub 

Private Sub UserForm_Initialize() 
 SpinButton1.Min = 10 
 SpinButton1.Max = 400 
 SpinButton1.Value = 100 
 Label1.Caption = SpinButton1.Value 

 CommandButton1.Caption = "Zoom it!" 
End Sub 

Private Sub UserForm_Zoom(Percent As Integer) 
 Dim MyResult As Double 

 If Percent > 99 Then 
 ScrollBars = fmScrollBarsBoth 
 ScrollLeft = 0 
 ScrollTop = 0 

 MyResult = Width * Percent / 100 
 ScrollWidth = MyResult 

 MyResult = Height * Percent / 100 
 ScrollHeight = MyResult 
 ScrollBars = fmScrollBarsNone 
 ScrollLeft = 0 
 ScrollTop = 0 
 End If 
End Sub
© 2018 Microsoft