Option Explicit
Dim sngFrmTop As Single
Dim sngFrmLeft As Single
Dim sngFrmHeight As Single
Dim sngFrmWidth As Single
Dim sngCntTop() As Single
Dim sngCntLeft() As Single
Dim sngCntHeight() As Single
Dim sngCntWidth() As Single
Dim sngCntFont() As Single
Private Sub Form_Load()
Dim a As Long
On Error GoTo Form_Load_Error
sngFrmTop = Top
sngFrmLeft = Left
sngFrmHeight = Height
sngFrmWidth = Width
ReDim sngCntTop(Controls.Count)
ReDim sngCntLeft(Controls.Count)
ReDim sngCntHeight(Controls.Count)
ReDim sngCntWidth(Controls.Count)
ReDim sngCntFont(Controls.Count)
For a = 0 To Controls.Count - 1
With Me.Controls(a)
sngCntTop(a) = (.Top / sngFrmHeight)
sngCntLeft(a) = (.Left / sngFrmWidth)
sngCntHeight(a) = (.Height / sngFrmHeight)
sngCntWidth(a) = (.Width / sngFrmWidth)
sngCntFont(a) = (.FontSize / sngFrmHeight)
End With
Next a
On Error GoTo 0
Exit Sub
Form_Load_Error:
If Err.Number = 13 Then
Resume Next
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Load of Form Form1"
End If
End Sub
Private Sub Form_Resize()
Dim a As Long
On Error GoTo Form_Resize_Error
sngFrmTop = Top
sngFrmLeft = Left
sngFrmHeight = Height
sngFrmWidth = Width
For a = 0 To Me.Controls.Count - 1
With Me.Controls(a)
.Top = sngFrmHeight * sngCntTop(a)
.Left = sngFrmWidth * sngCntLeft(a)
.Height = sngFrmHeight * sngCntHeight(a)
.Width = sngFrmWidth * sngCntWidth(a)
.FontSize = Int(sngFrmHeight * sngCntFont(a))
End With
Next a
On Error GoTo 0
Exit Sub
Form_Resize_Error:
If Err.Number = 383 Then 'Catch Error for controls with read only properties
Resume Next
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure Form_Resize of Form Form1"
End If
End Sub