PDA

Click to See Complete Forum and Search --> : Create your Own Progress Bar


Mark Gambo
May 9th, 2005, 03:46 PM
I found this code on Tripod (http://cuinl.tripod.com/Tips/percentbar.htm) and it works pretty well:

'This code will make a percentage progress bar, like those in installation programs.
'Add 1 PictureBox and 1 CommandButton to your form.
'Set The PictureBox DrawMode property to 6 - Invert.
'Insert the following code to your form:

Sub PerCnt(iNewValue As Integer)
If iNewValue > 100 Or iNewValue < 0 Then
Beep
Exit Sub
End If
Picture1.Cls
Picture1.FontSize = 12
Picture1.ScaleMode = 0
Picture1.ScaleWidth = 100
Picture1.ScaleHeight = 10
Picture1.CurrentY = 2
Picture1.CurrentX = Picture1.ScaleWidth / 2 - (Picture1.ScaleWidth / 15)
Picture1.Print Str(iNewValue) & "%"
Picture1.Line (0, 0)-(iNewValue, Picture1.ScaleHeight), Picture1.FillColor, BF
End Sub

Private Sub Command1_Click()
Dim a As Long
Dim b As Long

For a = 1 To 100
PerCnt CInt(a)
For b = 1 To 20000000: Next b
Next a
End Sub

wiz126
Jul 25th, 2005, 05:14 PM
The way u changed it from the website made it uncontroable. since your variable r not set-able if the % didn't get to 100% if might cuss the application to frize or even might make u restart the computer. u might want to make some veriables like a timer to do it for u

let x b the % for your picutre
just set your timer interval to anywhere from 50 to 100 just for the hack of it


:ehh: :ehh: :ehh:

Dim x As Integer
Sub PerCnt(iNewValue As Integer)
If iNewValue > 100 Or iNewValue < 0 Then
Beep
Exit Sub
End If
Picture1.Cls
Picture1.FontSize = 12
Picture1.ScaleMode = 0
Picture1.ScaleWidth = 100
Picture1.ScaleHeight = 10
Picture1.CurrentY = 2
Picture1.CurrentX = Picture1.ScaleWidth / 2 - (Picture1.ScaleWidth / 15)
Picture1.Print Str(iNewValue) & "%"
Picture1.Line (0, 0)-(iNewValue, Picture1.ScaleHeight), Picture1.FillColor, BF
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False 'make the timer stop so no error will happend
End Sub

Private Sub Timer1_Timer()
x = x + 1
PerCnt CInt(x)
End Sub


:ehh: :ehh: :ehh: