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_

Inputs

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

Code

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
.Cls

'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

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.