Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Create a progress bar from a PictureBox
The following code demonstrates a simple technique for turning a VB PictureBox into a progress bar.
'Purpose : Creates a progress bar from a picture box
'Inputs : pbProgress The picture box.
' lPercentComplete The percentage complete of the progress bar.
' [lBackColor] The backcolor of the progress bar (default uses system backcolor).
' [lForeColor] The forecolor of the progress bar (default uses blue).
'Outputs : Returns 0 on success, else returns an error code
'Notes : Example usuage:
' DrawProgressBar Picture1, 10 'Draws the progress bar 10% complete
Function DrawProgressBar(pbProgress As PictureBox, lPercentComplete As Long, Optional lBackColor As OLE_COLOR = &H8000000F, Optional lForeColor As OLE_COLOR = vbBlue) As Long
Dim fPercent As Single
Dim lLenBar As Integer
On Error GoTo ErrFailed
fPercent = lPercentComplete / 100
lLenBar = fPercent * pbProgress.ScaleWidth
'Fill both sides of the bar (incase a backwards progress bar is required)
pbProgress.AutoRedraw = True
pbProgress.BackColor = lBackColor
pbProgress.ForeColor = lForeColor
pbProgress.Line (0, 0)-(lLenBar, pbProgress.Height), pbProgress.ForeColor, BF
pbProgress.Line (lLenBar + 1, 0)-(pbProgress.ScaleWidth, pbProgress.Height), pbProgress.BackColor, BF
DrawProgressBar = 0
Exit Function
ErrFailed:
Debug.Print "Error in DrawProgressBar: " & Err.Description
Debug.Assert False
DrawProgressBar = Err.Number
End Function
I have not ever been able to turn a picture box vertical.