VB Code:
'the "magical" sub... lol
Public Sub GrowShrink(MaxWidth As Long, MaxHeight As Long, MinWidth As Long, MinHeight As Long, GrowSpeed As Integer, ShrinkSpeed As Integer, frm As Form)
Do
If frm.Width < MaxWidth Then
frm.Width = frm.Width + GrowSpeed
End If
If frm.Height < MaxHeight Then
frm.Height = frm.Height + GrowSpeed
End If
frm.Move (Screen.Width - frm.Width) / 2, (Screen.Height - frm.Height) / 2
DoEvents
If frm.Height >= MaxHeight And frm.Width >= MaxWidth Then Exit Do
Loop
Do
If frm.Width > MinWidth Then
frm.Width = frm.Width - ShrinkSpeed
End If
If frm.Height > MinHeight Then
frm.Height = frm.Height - ShrinkSpeed
End If
frm.Move (Screen.Width - frm.Width) / 2, (Screen.Height - frm.Height) / 2
DoEvents
If frm.Height <= MinHeight And frm.Height <= MinWidth Then Exit Do
Loop
End Sub
'and to use it:
Private Sub Form_Load()
Me.Visible = True
GrowShrink 10000, 10000, 3000, 3000, 25, 50, Me
End Sub