progress bar with running %

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andras Gilicz

    progress bar with running %

    Hi VB fans

    Is there a simple way to create a progress bar with a running % in the
    middle? The standard progress bar of VB6 cannot do it. How can I make
    the % number progressively inverted, as the bar passes it?

    Tx for any help.

    Andras
  • Veign

    #2
    Re: progress bar with running %

    Creating a Custom PhotoShop-Style ProgressBar:


    --
    Chris Hanscom
    MVP (Visual Basic)
    Veign, Columbia. 119 likes. A South Carolina development company whose primary focus is to leverage the power of machine learning to better understand your data. From image and object detection to...

    --

    "Andras Gilicz" <agilicz@chello .hu> wrote in message
    news:729e2243.0 409071009.4c677 6fd@posting.goo gle.com...[color=blue]
    > Hi VB fans
    >
    > Is there a simple way to create a progress bar with a running % in the
    > middle? The standard progress bar of VB6 cannot do it. How can I make
    > the % number progressively inverted, as the bar passes it?
    >
    > Tx for any help.
    >
    > Andras[/color]


    Comment

    • M. Godfrey

      #3
      Re: progress bar with running %

      Ok Check it out:
      start a new project for this example, you will need the following controls:

      1 PictureBox - name: Pic
      1 CommandButton - name: Command1

      Copy and Paste the following Code:

      Private Sub UpdateStatus(Pi c As PictureBox, ByVal sngPercent As Single,
      Optional ByVal fBorderCase As Boolean = False)
      Dim strPercent As String
      Dim intX As Integer
      Dim intY As Integer
      Dim intWidth As Integer
      Dim intHeight As Integer
      Dim intPercent As Integer
      'For this to work well, we need a white background and any color
      foreground (blue)
      Const colBackground = &HFFFFFF ' white
      Const colForeground = &H800000 ' dark blue
      Pic.ForeColor = colForeground
      Pic.BackColor = colBackground

      '
      'Format$ percentage and get attributes of text
      '
      intPercent = Int(100 * sngPercent + 0.5)

      'Never allow the percentage to be 0 or 100 unless it is exactly that
      value. This
      'prevents, for instance, the status bar from reaching 100% until we are
      entirely done.
      If intPercent = 0 Then
      If Not fBorderCase Then
      intPercent = 1
      End If
      ElseIf intPercent = 100 Then
      If Not fBorderCase Then
      intPercent = 99
      End If
      End If

      strPercent = Format$(intPerc ent) & "%"
      intWidth = Pic.TextWidth(s trPercent)
      intHeight = Pic.TextHeight( strPercent)
      '
      'Now set intX and intY to the starting location for printing the
      percentage
      '
      intX = Pic.Width / 2 - intWidth / 2
      intY = Pic.Height / 2 - intHeight / 2
      '
      'Need to draw a filled box with the pics background color to wipe out
      previous
      'percentage display (if any)
      '
      Pic.DrawMode = 13 ' Copy Pen
      Pic.Line (intX, intY)-Step(intWidth, intHeight), Pic.BackColor, BF
      '
      'Back to the center print position and print the text
      '
      'If m_ShowPercent = True Then
      Pic.CurrentX = intX
      Pic.CurrentY = 0 'intY

      Pic.Print strPercent
      'End If
      '
      'Now fill in the box with the ribbon color to the desired percentage
      'If percentage is 0, fill the whole box with the background color to
      clear it
      'Use the "Not XOR" pen so that we change the color of the text to white
      'wherever we touch it, and change the color of the background to blue
      'wherever we touch it.
      '
      Pic.DrawMode = 10 ' Not XOR Pen
      If sngPercent > 0 Then
      Pic.Line (0, 0)-(Pic.Width * sngPercent, Pic.Height), Pic.ForeColor,
      BF
      Else
      Pic.Line (0, 0)-(Pic.Width, Pic.Height), Pic.BackColor, BF
      End If
      Pic.Refresh
      End Sub


      Private Sub Command1_Click( )
      'Start the example loop
      For xloop = 1 To 1000
      tNumber = tNumber + 0.001 'This number is low due to the speed of the
      loop to slow it down so you can see the progress %
      UpdateStatus Pic, tNumber, True
      Next
      End Sub



      "Andras Gilicz" <agilicz@chello .hu> wrote in message
      news:729e2243.0 409071009.4c677 6fd@posting.goo gle.com...[color=blue]
      > Hi VB fans
      >
      > Is there a simple way to create a progress bar with a running % in the
      > middle? The standard progress bar of VB6 cannot do it. How can I make
      > the % number progressively inverted, as the bar passes it?
      >
      > Tx for any help.
      >
      > Andras[/color]


      Comment

      • Andras Gilicz

        #4
        Re: progress bar with running %

        "M. Godfrey" <mgodfreys1@yah oo.com> wrote in message news:<Z4udnZnOp br6Y9ncRVn-pw@comcast.com> ...[color=blue]
        > Ok Check it out:
        > start a new project for this example, you will need the following controls:
        >
        > 1 PictureBox - name: Pic
        > 1 CommandButton - name: Command1
        >
        > Copy and Paste the following Code:
        >
        > Private Sub UpdateStatus(Pi c As PictureBox, ByVal sngPercent As Single,
        > Optional ByVal fBorderCase As Boolean = False)
        > Dim strPercent As String
        > Dim intX As Integer
        > Dim intY As Integer
        > Dim intWidth As Integer
        > Dim intHeight As Integer
        > Dim intPercent As Integer
        > 'For this to work well, we need a white background and any color
        > foreground (blue)
        > Const colBackground = &HFFFFFF ' white
        > Const colForeground = &H800000 ' dark blue
        > Pic.ForeColor = colForeground
        > Pic.BackColor = colBackground
        >
        > '
        > 'Format$ percentage and get attributes of text
        > '
        > intPercent = Int(100 * sngPercent + 0.5)
        >
        > 'Never allow the percentage to be 0 or 100 unless it is exactly that
        > value. This
        > 'prevents, for instance, the status bar from reaching 100% until we are
        > entirely done.
        > If intPercent = 0 Then
        > If Not fBorderCase Then
        > intPercent = 1
        > End If
        > ElseIf intPercent = 100 Then
        > If Not fBorderCase Then
        > intPercent = 99
        > End If
        > End If
        >
        > strPercent = Format$(intPerc ent) & "%"
        > intWidth = Pic.TextWidth(s trPercent)
        > intHeight = Pic.TextHeight( strPercent)
        > '
        > 'Now set intX and intY to the starting location for printing the
        > percentage
        > '
        > intX = Pic.Width / 2 - intWidth / 2
        > intY = Pic.Height / 2 - intHeight / 2
        > '
        > 'Need to draw a filled box with the pics background color to wipe out
        > previous
        > 'percentage display (if any)
        > '
        > Pic.DrawMode = 13 ' Copy Pen
        > Pic.Line (intX, intY)-Step(intWidth, intHeight), Pic.BackColor, BF
        > '
        > 'Back to the center print position and print the text
        > '
        > 'If m_ShowPercent = True Then
        > Pic.CurrentX = intX
        > Pic.CurrentY = 0 'intY
        >
        > Pic.Print strPercent[/color]
        [color=blue]
        > 'End If
        > '
        > 'Now fill in the box with the ribbon color to the desired percentage
        > 'If percentage is 0, fill the whole box with the background color to
        > clear it
        > 'Use the "Not XOR" pen so that we change the color of the text to white
        > 'wherever we touch it, and change the color of the background to blue
        > 'wherever we touch it.
        > '
        > Pic.DrawMode = 10 ' Not XOR Pen
        > If sngPercent > 0 Then
        > Pic.Line (0, 0)-(Pic.Width * sngPercent, Pic.Height), Pic.ForeColor,
        > BF
        > Else
        > Pic.Line (0, 0)-(Pic.Width, Pic.Height), Pic.BackColor, BF
        > End If
        > Pic.Refresh
        > End Sub
        >
        >
        > Private Sub Command1_Click( )
        > 'Start the example loop
        > For xloop = 1 To 1000
        > tNumber = tNumber + 0.001 'This number is low due to the speed of the
        > loop to slow it down so you can see the progress %
        > UpdateStatus Pic, tNumber, True
        > Next
        > End Sub
        >
        >
        >
        > "Andras Gilicz" <agilicz@chello .hu> wrote in message
        > news:729e2243.0 409071009.4c677 6fd@posting.goo gle.com...[color=green]
        > > Hi VB fans
        > >
        > > Is there a simple way to create a progress bar with a running % in the
        > > middle? The standard progress bar of VB6 cannot do it. How can I make
        > > the % number progressively inverted, as the bar passes it?
        > >
        > > Tx for any help.
        > >
        > > Andras[/color][/color]

        tx for all of you for the help, I can use them!

        regards

        Andras

        Comment

        Working...