VB icon

Form gradient using three only lines of code

Email
Submitted on: 1/23/2015 5:48:00 PM
By: Behrooz Sangani (from psc cd)  
Level: Beginner
User Rating: By 4 Users
Compatibility: VB 6.0
Views: 495
 
     This is how to use gradient colors in a form. You do not need to do anything or write lines of code to add gradient to your forms. Just put the these three lines in Form_Load Sub Update Note: Thanks for comments, Form_Resize is a better sub if your form is not fixed size

 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Form gradient using three only lines of code
'**************************************
'none
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Form gradient using three only lines of code
' Description:This is how to use gradient colors in a form. You do not need to do anything or write lines of code to add gradient to your forms. Just put the these three lines in Form_Load Sub
Update Note: Thanks for comments, Form_Resize is a better sub if your form is not fixed size
' By: Behrooz Sangani (from psc cd)
'**************************************

'=============================================
' Form Gradient
' Add gradient with three lines of code
'=============================================
' Created By: Behrooz Sangani
' Published Date: 27/11/2001
' Email: bs20014@yahoo.com
' Use for free. No obligation!
'=============================================
Private Sub Form_Resize()
'You do not need to do anything or write lines of code _
to add gradient to your forms. Just put the following _
lines in Form_Resize Sub 
'This line is important. You must set the form autoredraw _
to true else nothing would happen. Another problem even _
if you manage to add gradient is you would not be able _
to use labels in your form. Try this and see the results _
labels can't become transparent.
AutoRedraw = True
'This form gradient is a little slow! To help gradient draw _ 
'faster you need to set your form ScaleMode to pixels. 
'This would do great, at least on my PC. 
 
ScaleMode = vbPixels
'Change RGB Numbers in For-Next to have your desired color.
' R=200, G=0, B=255
'Horizental Gradient
For Y = 0 To ScaleHeight
 Line (-1, Y - 1)-(ScaleWidth, Y + 1), RGB(200, 0, 255 - (Y * 255) \ ScaleHeight), B
Next Y
' If you want vertical gradient just reverse the variables. _
Like this:
' For X = 0 To ScaleWidth
' Line (X - 1, -1)-(X + 1, ScaleWidth), RGB(200, 0, 255 - (X * 255) \ ScaleWidth), B
' Next X
End Sub


Other 9 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.