Results 1 to 2 of 2

Thread: Progress Bar Text

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Question Progress Bar Text

    Does anybody have a way to make text "in the progress bar" that will change colors as the progress bar progresses ?

    Thanx in advance,
    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Here is a sample of how to do that using a picture box to make a progress bar.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub DrawProgress(ByVal Value As Long, ByVal Max As Long)
    4. Dim strPercent As String
    5. Dim intPercent As Integer
    6. Dim intWidth As Integer
    7. Dim intHeight As Integer
    8.  
    9.     intPercent = (Value / Max) * 100
    10.     strPercent = intPercent & "%"
    11.     intWidth = Picture1.TextWidth(strPercent)
    12.     intHeight = Picture1.TextHeight(strPercent)
    13.  
    14.     With Picture1
    15.         .FillStyle = vbFSSolid
    16.         .BackColor = vbWhite
    17.         .ForeColor = vbBlue
    18.         .DrawMode = vbCopyPen
    19.         .CurrentX = (Picture1.ScaleWidth - intWidth) / 2
    20.         .CurrentY = (Picture1.ScaleHeight - intHeight) / 2
    21.         Picture1.Print strPercent
    22.         .DrawMode = vbNotXorPen
    23.     End With
    24.  
    25.  
    26.     If intPercent > 0 Then
    27.         Picture1.Line (-50, -50)-(Picture1.Width * intPercent / 100, Picture1.Height), vbBlue, BF
    28.     Else
    29.         Picture1.Line (-50, -50)-(Picture1.Width, Picture1.Height), vbWhite, BF
    30.     End If
    31.     Picture1.Refresh
    32. End Sub
    33.  
    34. Private Sub Form_Load()
    35.     Timer1.Interval = 50
    36.     Timer1.Enabled = True
    37.     Picture1.AutoRedraw = True
    38. End Sub
    39.  
    40. Private Sub Timer1_Timer()
    41. Static i As Integer
    42. Dim lngMax As Long
    43.    
    44.     lngMax = 250
    45.    
    46.     If i > lngMax Then
    47.         i = 0
    48.     End If
    49.    
    50.     DrawProgress i, lngMax
    51.    
    52.     i = i + 1
    53. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width