I am really bored today, and just for no reason, I wrote this code. It has no real purpose, but it would look cool for a splash screen or something.
VB Code:
  1. 'the "magical" sub... lol
  2. Public Sub GrowShrink(MaxWidth As Long, MaxHeight As Long, MinWidth As Long, MinHeight As Long, GrowSpeed As Integer, ShrinkSpeed As Integer, frm As Form)
  3. Do
  4.     If frm.Width < MaxWidth Then
  5.         frm.Width = frm.Width + GrowSpeed
  6.     End If
  7.     If frm.Height < MaxHeight Then
  8.         frm.Height = frm.Height + GrowSpeed
  9.     End If
  10.     frm.Move (Screen.Width - frm.Width) / 2, (Screen.Height - frm.Height) / 2
  11.     DoEvents
  12.     If frm.Height >= MaxHeight And frm.Width >= MaxWidth Then Exit Do
  13. Loop
  14. Do
  15.     If frm.Width > MinWidth Then
  16.         frm.Width = frm.Width - ShrinkSpeed
  17.     End If
  18.     If frm.Height > MinHeight Then
  19.         frm.Height = frm.Height - ShrinkSpeed
  20.     End If
  21.     frm.Move (Screen.Width - frm.Width) / 2, (Screen.Height - frm.Height) / 2
  22.     DoEvents
  23.     If frm.Height <= MinHeight And frm.Height <= MinWidth Then Exit Do
  24. Loop
  25. End Sub
  26.  
  27. 'and to use it:
  28. Private Sub Form_Load()
  29. Me.Visible = True
  30. GrowShrink 10000, 10000, 3000, 3000, 25, 50, Me
  31. End Sub