devxlogo

Progress Bars With A Gradient

Progress Bars With A Gradient

The tip “Color Status Indicator” [“101 Tech Tips for VB Developers,” Supplement to the February 1997 issue of VBPJ, page 26] got me thinking that it would look even more attractive to have the status change color in gradient steps. Instead of changing the color at particular points, start at red, blend to orange, then yellow, and finally green.

To try this, place a Sheridan 3-D panel on your form and set the FloodType property to 1 (Left to Right) and ShowFloodPct to False. Place a command button and a text box (set the Caption to blank) on the form to do your testing. Place this code in the form:

 Private Sub Command1_Click()	Dim i As Integer, iIncrement As Integer	Dim iMidPoint As Integer, iCheckpoint As Integer	Dim j As Integer, sAddIncrement As String	Dim sSubIncrement As String	iIterations = Val(Text1)	iMidPoint = iIterations * 0.5 - 1	' find the midpoint	If iIterations / 510 = iIterations  510 Then		'perfect algorithm		iIncrement = 1		iCheckpoint = 1	ElseIf iIterations 

The effect works best when your video is set to at least 16-bit (High Color). Because there are exactly 510 progressive gradients between red and green, the number of iterations you enter will influence what shade of green you end up with. As the iterations increase (>900), you'll end up with bright green.

devx-admin

Share the Post: