by Anonymous (267 Submissions)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 19th November 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Create a Left to Right Gradient Form using the basic RGB colors. Quick and EZ.
'On the form create the following:
'3 Default Command Buttons (names should be: Command1, Command2, and Command3)
'1 Default Label (name should be: Label1)
'Change the Form StartupPosition property to Center Screen (2) if desired
'Don't worry about the size of the Form or placement of the Command Buttons or the Label.
'The program will change the default properties as needed.
'[There is more coding used to Setup postions than actually displaying the Gradient Form!]
'Now just copy everything below into the Code portion of the Form and Run it - that's it!
'The program is sparsely commented
Option Explicit
Dim lStep As Long 'Variable to Left Step the Line Drawing [Long Number]
Dim bc As Long 'Variable to keep track of the Line Color [Long Number]
Private Sub Form_Load()
'Note ----------------------------------------------------------------------------------
'The following is NOT Necessary IF your Form is Setup the way you want it!
'If you have your Form and Controls in place then you can delete all the "With Me"
'Properties in this Form_Load EXCEPT THE LAST ONE!
With Me
.BorderStyle = 1
.Caption = "EZ Left to Right Gradient Form"
.Height = 8145
.Width = 11745
End With
With Command1
.Caption = "EZ Red"
.Height = 255
.Left = 1080
.Top = 6960
.Width = 1455
End With
With Command2
.Caption = "EZ Green"
.Height = 255
.Left = 5280
.Top = 6960
.Width = 1455
End With
With Command3
.Caption = "EZ Blue"
.Height = 255
.Left = 8880
.Top = 6960
.Width = 1455
End With
With Label1
.Alignment = 2
.AutoSize = True
.BackStyle = 0
.Caption = "Some Label1 Properties: [.BackStyle = 0 - Transparent] [.Font.Size = 10] [Font.Bold = True]"
.ForeColor = vbWhite
.Font.Size = 10
.Font.Bold = True
.Top = ((Me.Height / 2) - (Label1.Height / 2)) 'Roughly Center the Label Vertically
.Left = ((Me.Width / 2) - (Label1.Width / 2)) 'Roughly Center the Label Horizontally
.Visible = False
End With
'End of Setup -----------------------------------------------------------
' The "With Me" Below item HAS TO remain for a speedy display!!!
With Me
.AutoRedraw = True
.DrawStyle = vbInsideSolid
.DrawMode = vbCopyPen
.DrawWidth = 2
.ScaleMode = vbPixels
End With
End Sub
Private Sub Command1_Click() 'Ez Red
Label1.Visible = True
For lStep = ScaleLeft To ScaleWidth
Line (lStep, bc)-(lStep, ScaleHeight), RGB(bc + (lStep / 2), 0, 0) 'Red - Note: all calls the same
Next lStep 'execpt placement of the
End Sub 'R(ed), G(reen), B(lue)
Private Sub Command2_Click() 'Ez Green
Label1.Visible = True
For lStep = ScaleLeft To ScaleWidth
Line (lStep, bc)-(lStep, ScaleHeight), RGB(0, bc + (lStep / 2), 0) 'Green
Next lStep
End Sub
Private Sub Command3_Click() 'Ez Blue
Label1.Visible = True
For lStep = ScaleLeft To ScaleWidth
Line (lStep, bc)-(lStep, ScaleHeight), RGB(0, 0, bc + (lStep / 2)) 'Blue
Next lStep
End Sub
No comments have been posted about Create a Left to Right Gradient Form using the basic RGB colors. Quick and EZ.. Why not be the first to post a comment about Create a Left to Right Gradient Form using the basic RGB colors. Quick and EZ..