Sub ResizeForm(ByVal AnyForm)
Dim iCount
Dim lrRatioWidth
Dim ctrl
Dim bDone
lrRatioWidth = Screen.Width / AnyForm.Width
AnyForm.Move 0, 0, Screen.Width, AnyForm.Height
On Error Resume Next
Do
Set ctrl = AnyForm.Controls(i)
If Err.Number <> 0 Then
bDone = True
Else
ctrl.Left = ctrl.Left * lrRatioWidth
ctrl.Width = ctrl.Width * lrRatioWidth
i = i + 1
End If
Loop Until bDone = True
End Sub
Listing 1 This code calculates what the form's rate of increase will be after resizing, then resizes the form and changes the size of each control in the form's control collection by the same ratio.