Public Class Form1Friend WithEvents btnTimer As New TimerDim RedValue As IntegerDim GreenValue As IntegerDim BlueValue As IntegerDim RAdd As Integer = 0Dim Gadd As Integer = 0Dim Badd As Integer = 0Dim MyBackColor As ColorPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadbtnTimer.Stop()MyBackColor = Button1.BackColorEnd SubPrivate Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseLeaveRedValue = CInt(MyBackColor.R) - CInt(Button1.FlatAppearance.MouseOverBackColor.R)GreenValue = CInt(MyBackColor.G) - CInt(Button1.FlatAppearance.MouseOverBackColor.G)BlueValue = CInt(MyBackColor.B) - CInt(Button1.FlatAppearance.MouseOverBackColor.B)RAdd = 0Gadd = 0Badd = 0btnTimer.Interval = 1btnTimer.Start()End SubPrivate Sub btnTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTimer.TickSelect Case RedValueCase Is <>RAdd = RAdd - 1RedValue = RedValue + 1Case Is > 0RAdd = RAdd + 1RedValue = RedValue - 1Case Is = 0RAdd = RAdd + 0End SelectSelect Case GreenValueCase Is <>Gadd = Gadd - 1GreenValue = GreenValue + 1Case Is > 0Gadd = Gadd + 1GreenValue = GreenValue - 1Case Is = 0Gadd = Gadd + 0End SelectSelect Case BlueValueCase Is <>Badd = Badd - 1BlueValue = BlueValue + 1Case Is > 0Badd = Badd + 1BlueValue = BlueValue - 1Case Is = 0Badd = Badd + 0End SelectButton1.BackColor = Color.FromArgb(CInt(Button1.FlatAppearance.MouseOverBackColor.R) + RAdd, CInt(Button1.FlatAppearance.MouseOverBackColor.G) + Gadd, CInt(Button1.FlatAppearance.MouseOverBackColor.B) + Badd)If BlueValue = 0 And RedValue = 0 And GreenValue = 0 ThenbtnTimer.Stop()End If
Thursday, October 8, 2009
Automatically fading buttons in VB.NET
I often find myself obsessing over the finer parts of interface design with my applications. I always thought buttons that innocuously faded from their mouseover color back to their default background color was something really nice and not *too* flashy. Since I couldn't find any material for replicating this in VB.NET I did what all programmers do, I wrote one myself. I hope this code helps anyone attempting to do something similar. Improve upon it if you wish, I am just posting the basic code, it will works best if you encapsulate it in a UserControl...
Friday, January 23, 2009
Access 2003 Using DateDiff for "Business Days" or Weekdays without using outside module
I see this problem alot among developers and I just thought id share some info. If you are using a very simple DBMS like Access 2003 and can't extend functionality to your standalone application, because access 2003 doesn't let you use UDF (User defined functions) outside of itself. Here is how I came up with determing the amount of WEEKDAYS (M-F) between two dates without having to create a UDF in the DB.
SELECT * FROM tblExample WHERE datediff('ww',[fldDate],Date(),2) + datediff('ww',[fldDate],date(),3) + datediff('ww',[fldDate],Date(),4) + datediff('ww',[fldDate],Date(),5) + datediff('ww',[fldDate],Date(),6) >= 5That will return all records where fldDate and Date() are greater than or equal to 5 weekdays. Of course if you can use custom functions in your DBMS, then you wont need this.
Subscribe to:
Posts (Atom)