by Walter Eigner (15 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 20th July 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Creates a progress bar on a picture box. Handy for making customized progress bars. Displays percentage in middle as well. Contact me if you
On Local Error GoTo Err: 'if we encounter errors don't bother continuing
Dim strPercent As String 'define all variables
Dim intWidth As Integer
Dim intHeight As Integer
Dim intX As Integer
Dim intY As Integer
Dim intPercent As Integer
pic.AutoRedraw = True 'make sure autoredraw is on
pic.ForeColor = colForeground 'set colors
pic.BackColor = colBackground
intPercent = Int(100 * sngPercent) 'format into percentage
strPercent = Str(intPercent) & "%" 'put a percentage sign after
intWidth = pic.TextWidth(strPercent) 'use width and height of text to
intHeight = pic.TextHeight(strPercent)
intX = pic.Width / 2 - intWidth / 2 'calculate where to center the percentage
intY = pic.Height / 2 - intHeight / 2
pic.DrawMode = 13 'copy pen
pic.Line (intX, intY)-Step(intWidth, intHeight), pic.BackColor, BF
pic.CurrentX = intX 'position writing place
pic.CurrentY = intY
pic.Print strPercent 'print text
pic.DrawMode = 10 'not xor
If sngPercent > 0 Then 'if percentage is greater that 0 then
pic.Line (0, 0)-(pic.Width * sngPercent, pic.Height), pic.ForeColor, BF 'paint a rectangle of the appropriate width
Else 'otherwise
pic.Line (0, 0)-(pic.Width, pic.Height), pic.BackColor, BF 'clear it
End If
pic.Refresh 'refresh it
UpdateProgress = True 'if no errors encountered return true
Exit Function
Err:
UpdateProgress = False 'we encountered errors - return false
End Function
No comments have been posted about Creates a progress bar on a picture box. Handy for making customized progress bars. Displays percen. Why not be the first to post a comment about Creates a progress bar on a picture box. Handy for making customized progress bars. Displays percen.