hi. soo i got this codes off of some site.
its for a cool form entry and exit effect.
but since im using this in my project i need to know what this lines of codes mean.
and i mean every line.
the site where i got it from doesnt offer this info which i need.
im hoping that you guys could help me out with this.
i need to explain every line of code in class.

you will need :
2 timers for this.
first timers set to true. the others false. each with 15 interval.

heres the code.

Option Explicit
Dim X As Integer, Y As Integer

Private Sub Form_Load()
    X = Me.Width
    Y = Me.Height
    Me.Width = 0
    Me.Height = 0
    Me.Left = (Screen.Width - Me.Width) / 2
    Me.Top = (Screen.Height - Me.Height) / 2
End Sub

Private Sub Timer1_Timer()
 'Timer for the opening event
If Me.Width < X Then
Me.Left = (Screen.Width - Me.Width) / 2
Me.Width = Me.Width + 400
Exit Sub
ElseIf Me.Width > X Then
Me.Width = X
End If

If Me.Height < Y Then
Me.Top = (Screen.Height - Me.Height) / 2
Me.Height = Me.Height + 350
Exit Sub
ElseIf Me.Height > Y Then
Me.Height = Y
End If
Timer1.Enabled = False
End Sub

Private Sub Timer2_Timer()
Do While Me.Width > 1800
Me.Width = Me.Width - 300
Me.Left = Me.Left + 150
If Me.Height - 400 Then
Me.Top = Me.Top - 1
Me.Height = Me.Height - 150
End If
Me.Refresh
DoEvents
Loop
Unload Form1: End
End Sub
Option Explicit
Dim X As Integer, Y As Integer 'Declare variable X and Y as Integer 

Private Sub Form_Load()
    ' This following code to assing variable X and Y with Width and Height of Form
    X = Me.Width 'assign variable X with form Width 
    Y = Me.Height 'assign variable Y with form Height
	
    'This following code to set Width and height of Form To 0
    Me.Width = 0 ' Set form Width to 0
    Me.Height = 0 ' Set form Height to 0
	
    ' This following to centered form
    Me.Left = (Screen.Width - Me.Width) / 2 ' Set Left with (Width of your computer screen -  Width of form) then Divide it by 2
    Me.Top = (Screen.Height - Me.Height) / 2 ' Set Top with (Height of your computer screen -  Height of form) then Divide it by 2
End Sub

'THis for Opened Form Animation
Private Sub Timer1_Timer()
 'Timer for the opening event
' This following code will  bringin back Form Size.. 
' form will increase width by 400 and Height by 350. So it will seems like animation..

' This following code will bring the Form Width Size
If Me.Width < X Then ' If Width of Form < X  (X is Form Width. Look at asiggnment in form load)
	Me.Left = (Screen.Width - Me.Width) / 2 'Set Left with (Width of your computer screen -  Width of form) then Divide it by 2. This for centered form
	Me.Width = Me.Width + 400 ' Form Width will increase by 400 until Width => X
	Exit Sub ' Exit this sub if form width is same or more than X
ElseIf Me.Width > X Then 'Else when increasing form width if with more than X then Set to X
	Me.Width = X ' Set Form width to X
End If

' This following code will bring the Form Width Size
' Increasing of Height has same explanation like Width
If Me.Height < Y Then
	Me.Top = (Screen.Height - Me.Height) / 2
	Me.Height = Me.Height + 350
	Exit Sub
ElseIf Me.Height > Y Then
	Me.Height = Y
End If
Timer1.Enabled = False ' Disable Timer (Stop)
End Sub

'THis for Closing Form Animation
Private Sub Timer2_Timer()
Do While Me.Width > 1800 'this event will running until Form Width 
	Me.Width = Me.Width - 300 ' Form Width size will decrease by 300
	Me.Left = Me.Left + 150 ' Form Left will increase by 150. So form seems like moving to right
	If Me.Height - 400 Then '
		Me.Top = Me.Top - 1 ' Form Top will decrease by 1
		Me.Height = Me.Height - 150 'Form height size will decrease by 150
	End If
	Me.Refresh ' refresh form
	DoEvents
Loop  ' loop with condition
Unload Form1: End 'closing form
End Sub
commented: Very good explanation +2
Option Explicit
Dim X As Integer, Y As Integer 'Declare variable X and Y as Integer 

Private Sub Form_Load()
    ' This following code to assing variable X and Y with Width and Height of Form
    X = Me.Width 'assign variable X with form Width 
    Y = Me.Height 'assign variable Y with form Height
	
    'This following code to set Width and height of Form To 0
    Me.Width = 0 ' Set form Width to 0
    Me.Height = 0 ' Set form Height to 0
	
    ' This following to centered form
    Me.Left = (Screen.Width - Me.Width) / 2 ' Set Left with (Width of your computer screen -  Width of form) then Divide it by 2
    Me.Top = (Screen.Height - Me.Height) / 2 ' Set Top with (Height of your computer screen -  Height of form) then Divide it by 2
End Sub

'THis for Opened Form Animation
Private Sub Timer1_Timer()
 'Timer for the opening event
' This following code will  bringin back Form Size.. 
' form will increase width by 400 and Height by 350. So it will seems like animation..

' This following code will bring the Form Width Size
If Me.Width < X Then ' If Width of Form < X  (X is Form Width. Look at asiggnment in form load)
	Me.Left = (Screen.Width - Me.Width) / 2 'Set Left with (Width of your computer screen -  Width of form) then Divide it by 2. This for centered form
	Me.Width = Me.Width + 400 ' Form Width will increase by 400 until Width => X
	Exit Sub ' Exit this sub if form width is same or more than X
ElseIf Me.Width > X Then 'Else when increasing form width if with more than X then Set to X
	Me.Width = X ' Set Form width to X
End If

' This following code will bring the Form Width Size
' Increasing of Height has same explanation like Width
If Me.Height < Y Then
	Me.Top = (Screen.Height - Me.Height) / 2
	Me.Height = Me.Height + 350
	Exit Sub
ElseIf Me.Height > Y Then
	Me.Height = Y
End If
Timer1.Enabled = False ' Disable Timer (Stop)
End Sub

'THis for Closing Form Animation
Private Sub Timer2_Timer()
Do While Me.Width > 1800 'this event will running until Form Width 
	Me.Width = Me.Width - 300 ' Form Width size will decrease by 300
	Me.Left = Me.Left + 150 ' Form Left will increase by 150. So form seems like moving to right
	If Me.Height - 400 Then '
		Me.Top = Me.Top - 1 ' Form Top will decrease by 1
		Me.Height = Me.Height - 150 'Form height size will decrease by 150
	End If
	Me.Refresh ' refresh form
	DoEvents
Loop  ' loop with condition
Unload Form1: End 'closing form
End Sub

thankyou so much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.