Knowledge speaks, but wisdom listens.
- Jimi Hendrix
News
Site News
Latest Comments
Affiliates
Proxies
Contribute!
Chat
Tutorials
Newest Articles
Most Popular
Highest Rated
Latest Comments
Code Samples
Newest Code
Most Popular
Highest Rated
Latest Comments
Blogs
Admins Blog
Newest Blogs
Most Popular
Highest Rated
Latest Comments
Forums
Latest Posts
Latest Topics
Memberlist
[login]
|
[Register]
RGB Color Fader
by: bs0d
Description:
Once you get the items in the form: 3 text boxes, the shape (can be any shape) and 3 buttons, this program should work. Be sure to name them appropriately to the code.
See Full Size
Code:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub cmdClear_Click() 'Will clear the contents of the RGB numbers entered txtRed = "" txtGreen = "" txtBlue = "" txtRed.SetFocus 'Will set the shape color back to default black. shpSquare.FillColor = vbBlack shpSquare.Refresh End Sub Private Sub cmdExit_Click() 'Will terminate the program Unload Me End End Sub Private Sub cmdFader_Click() 'This will flow through the Colors in the Color Pallete 'Using the ever famous, RGB Function. For R = 0 To 255 shpSquare.FillColor = RGB(R, Val(txtGreen), Val(txtBlue)) shpSquare.Refresh Sleep 10 Next R For G = 0 To 255 shpSquare.FillColor = RGB(Val(txtRed), G, Val(txtBlue)) shpSquare.Refresh Sleep 10 Next G For B = 0 To 255 shpSquare.FillColor = RGB(Val(txtRed), Val(txtGreen), B) shpSquare.Refresh Sleep 10 Next B End Sub Private Sub Form_Load() 'Will center the form on the screen frmFader.Top = (Screen.Height - frmFader.Height) / 2 frmFader.Left = (Screen.Width - frmFader.Width) / 2 End Sub Private Sub txtBlue_Change() 'This will make sure that the user does not enter a number 'Larger than 255 or 0, because it would not function properly. If Val(txtBlue) > 255 Then intRes = MsgBox("Number cannot be larger than 255.", vbExclamation, "ALERT!!!") txtBlue = "" txtBlue.SetFocus ElseIf Val(txtBlue) < 0 Then intRes = MsgBox("Number cannot be smaller than zero.", vbExclamation, "ALERT!!!") txtBlue = "" txtBlue.SetFocus End If End Sub Private Sub txtGreen_Change() 'This will make sure that the user does not enter a number 'Larger than 255 or 0, because it would not function properly. If Val(txtGreen) > 255 Then intRes = MsgBox("Number cannot be larger than 255.", vbExclamation, "ALERT!!!") txtGreen = "" txtGreen.SetFocus ElseIf Val(txtGreen) < 0 Then intRes = MsgBox("Number cannot be smaller than zero.", vbExclamation, "ALERT!!!") txtGreen = "" txtGreen.SetFocus End If End Sub Private Sub txtRed_Change() 'This will make sure that the user does not enter a number 'Larger than 255 or 0, because it would not function properly. If Val(txtRed) > 255 Then intRes = MsgBox("Number cannot be larger than 255.", vbExclamation, "ALERT!!!") txtRed = "" txtRed.SetFocus ElseIf Val(txtRed) < 0 Then intRes = MsgBox("Number cannot be smaller than zero.", vbExclamation, "ALERT!!!") txtRed = "" txtRed.SetFocus End If End Sub
No Comments for this page.
You Must be
signed in
or a
member
to comment.
Code Stats
17,646
Views
0
Total Comments
5
Rating of 5 (
4
Votes)
Code Options
·
Login to Rate This Code
·
Login to Post a Comment
·
Read more by this author
Related
·
Adder
·
Math Problems
·
Cut and Paste
·
Combo Box Colors
·
Flag Viewer
"AllSyntax.com" Copyright © 2002-2021; All rights lefted, all lefts righted.
Privacy Policy