VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



ImprovedCool Form Close

by Jono Spiro (4 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

'This is a much improved version of the cool form close code submitted by Jas Batra. It shrinks the First of all, it is in function form, second it is a 'lot' faster and smoother. Code is fully documented for beginners.

Inputs
'Inputs are: ' coolCloseForm closeForm,speed 'closeform is the form to close 'speed is anything from 1 to about 100 or more...
Assumes
'Completely documented for beginners.
Code Returns
'Nothing
Side Effects
'None so far, make sure that no data will be lost, because when this code runs, it unloads the form.
API Declarations
'None

Rate ImprovedCool Form Close

'If you want to try this code in action:
' make a new project and add a module
'double click on the form and add the following code:
Private Sub Form_Load()
 Form1.Height = 6400
 Form1.Width = 10000
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
 If Button = vbRightButton Then
 coolCloseForm Me, 20
 Else
 Dim a As New Form1
 a.Height = a.Height / 2
 a.Width = a.Width / 2
 a.Show
 End If
End Sub
'Then add the coolCloseForm code to the module
'Now run the program, left click a few times to add new forms to screen, and then right click on them to make them go away.
'END OF EXAMPLE CODE
'
'
'
'ALL CODE BELOW TO THE BOTTOM IS THE ACTUAL MODULE CODE, ABOVE CODE IS ALL OPTIONAL!!
'
Public Function coolCloseForm(closeForm As Form, speed As Integer)
 'make sure speed is more than 1
 If speed = 0 Then
 MsgBox "Speed cannot zero"
 Exit Function
 End If
 'closeform is the form to close
 'speed is anything from 1 to about 100
 On Error Resume Next
 'set the scalemode to twips so that the do statements will work
 closeForm.ScaleMode = 1
 'so the code wont crash
 closeForm.WindowState = 0
 'do until the height is the minimum possible
 Do Until closeForm.Height <= 405
 'let the computer process
 DoEvents
 'make the form shorter by the speed * 10
 closeForm.Height = closeForm.Height - speed * 10
 'make the top of the form lower by the speed * 5
 closeForm.Top = closeForm.Top + speed * 5
 Loop
 'do until the width is the minimum possible
 Do Until closeForm.Width <= 1680
 'let the computer process
 DoEvents
 'make the form less wide by the speed * 10
 closeForm.Width = closeForm.Width - speed * 10
 'make the left of the form farther to the righ by the speed * 5
 closeForm.Left = closeForm.Left + speed * 5
 Loop
 'when its all done, unload the form
 Unload closeForm
End Function

Download this snippet    Add to My Saved Code

ImprovedCool Form Close Comments

No comments have been posted about ImprovedCool Form Close. Why not be the first to post a comment about ImprovedCool Form Close.

Post your comment

Subject:
Message:
0/1000 characters