Search Tools Links Login

Percent Bar - Transforms a PictureBox into a Percent Bar!

I thought this code might help those struggling to make a percent bar. This code transforms a normal picturebox into a Percent Bar (progress bar with % in the middle). Choose from 2 different borders.

Original Author: _andy_


pic As PictureBox, ByVal Percent As Integer, Optional ByVal Flat As Boolean = False


Public Sub UpdateProgress(pic As PictureBox, ByVal Percent As Single, Optional ByVal Flat As Boolean = False)
With pic
'Configure PictureBox
.AutoRedraw = True
.Appearance = Flat + 1
.ScaleWidth = 100
.ForeColor = vbHighlight
.BackColor = vbButtonFace
.DrawMode = vbNotXorPen

'Clear the PictureBox

'Draw the text
.CurrentX = (.ScaleWidth - .TextWidth(Int(Percent) & "%")) 2
.CurrentY = (.ScaleHeight - .TextHeight(Int(Percent) & "%")) 2
pic.Print Int(Percent) & "%"

'Draw the progress
pic.Line (0, 0)-(Percent, .ScaleHeight), , BF
End With
End Sub

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 91 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.