Results 1 to 12 of 12

Thread: Progressbar

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Nova Scotia, Canada
    Posts
    10

    Question

    Does anyone know if you can change the color of the progressbar from that lovely shade of blue to another color?
    And is it possible to make it move from right to left instead of left to right?

    Just curious...thanks

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'you could make your own..the right to left I've never tried
    Code:
    'use a progress bar
    'make a standard app and add a picture box called Progress
    'in the PublicSub DoProgress..rename the frmSaveApps to your form name
    'cut and paste the code and run to see an example
    '
    '<<<<<<<  Put this in a bas module  >>>>>>>>
    
    'replace frmTips with the name of your app form
    'or name your form frmTips for this example
    
    Option Explicit
    
    'number of things to do ex..files to be backed up
    Public intCounted#  
    '
    Public Sub DoProgress(Percent)
    '
    ' Percent is % of graph
    '
    Dim Work As Integer
    Dim Num As String
    '
    Work = Int(Abs(Percent))
    If Work > 100 Then Work = 100
    '
    With frmSaveTips.Progress       '<<<   With application form
        .BackColor = vbWhite        '<<<   White background
        If Not .AutoRedraw Then     '<<<   picture in memory ?
        .AutoRedraw = True          '<<<   make one
        End If
        
        .Cls                        '<<<   clear picture in memory
        .ScaleWidth = 100           '<<<   new scalemodus
        .DrawMode = 10              '<<<   not XOR Pen Modus
    
        Num = Format$(Work, "###") + "% Completed"
    
        .CurrentX = 50 - .TextWidth(Num) / 2         '<<<  %age is Centered
    
        .CurrentY = (.ScaleHeight - .TextHeight(Num)) / 2
    
        frmSaveTips.Progress.ForeColor = vbBlack     '<<<  Black text
        frmSaveTips.Progress.Print Num               '<<<  print percent
    
        frmSaveTips.Progress.Line (0, 0)-(Work, .ScaleHeight), vbBlue, BF
        .Refresh          '<<<  show
    End With
    '
    End Sub
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    '  <<<<<<<<<<<<   event code for form   >>>>>>>>>>>>>>>>>>>
    
    Private Sub Command1_Click()
    
    intTotalCount = 1000    'whatever..use 1000 for this example
    
    'print the line & increment the count
    
    Dim i, copied
    
    For i = 1 To 1000
     
        Print "This is a progress bar sample!"
        
        copied = copied + 1    'increment for progress bar
        Call DoProgress(copied / intTotalCount * 100)   'progress bar set to 100
     Next i
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I have a Active X control that does exactly what you have just said.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  4. #4
    Hyperactive Member barrk's Avatar
    Join Date
    Sep 2000
    Location
    My own little world
    Posts
    274
    Are you going to share??????

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Nova Scotia, Canada
    Posts
    10

    Smile

    Thanks HeSaidjoe,

    Never thought of making my own before, I'm relatively new to VB...I wonder if I can modify it to move from right to left...I'll work on that.

    And Electroman, if you could send me the Active X control via email to:
    [email protected]
    I'd appreciate it!!
    Or share it here for everyone to see...

    Thanks everyone!

  6. #6
    Guest
    Here is how to change the color of a Progressbar:

    Code:
    Private Declare Function SendMessage Lib "user32" Alias _
       "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
        ByVal wParam As Long, lParam As Any) As Long
        
    Private Const WM_USER = &H400
    
    'Found these only in the COMMCTRL.H file that
    'is installed with VC++
    
    Private Const PBM_SETBARCOLOR = WM_USER + 9
    Private Const PBM_SETBKCOLOR = &H2000 + 1
    
    Public Function SetPBBackColor(ProgressBar As Object, _
       NewColor As OLE_COLOR) As Boolean
    
    On Error Resume Next
    Dim lRet As Long
    lRet = SendMessage(ProgressBar.hwnd, PBM_SETBKCOLOR, 0&, NewColor)
    
    End Function
    
    Public Function SetPBBarColor(ProgressBar As Object, _
       NewColor As OLE_COLOR) As Boolean
    
    On Error Resume Next
    Dim lRet As Long
    lRet = SendMessage(ProgressBar.hwnd, PBM_SETBARCOLOR, 0&, NewColor)
    
    End Function
    
    
    'Usage:
    
    SetPBBackColor ProgressBar1, vbRed

  7. #7
    Hyperactive Member barrk's Avatar
    Join Date
    Sep 2000
    Location
    My own little world
    Posts
    274
    Thanx Matt!! Works great and looks good too!!!!!!!!!!!

  8. #8

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Nova Scotia, Canada
    Posts
    10

    Smile Thanks

    Yes, thanks Matthew, I really appreciate it!

  9. #9
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I'll post the control as soon as I can find out where I downloaded it form K ?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  10. #10
    New Member
    Join Date
    Jul 2000
    Location
    UK
    Posts
    5

    Thumbs up

    Will the examples given work in Excel 97 VBA?
    I want to display a progress bar while Excel runs a large macro.
    I've tried making one on a UserForm, but it stops the macro running, and I don't know how to make it not modal.
    Thanks
    Steve

  11. #11
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Thumbs up Try this

    www.vbweb.f9.co.uk

    Is the address I mentioned that you can get the vbWebProgressBar From.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  12. #12
    Hyperactive Member barrk's Avatar
    Join Date
    Sep 2000
    Location
    My own little world
    Posts
    274

    Smile

    Thank you Electroman! Much appreciated.

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