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
Printable View
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
'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
I have a Active X control that does exactly what you have just said.
Are you going to share??????
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!
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
Thanx Matt!! Works great and looks good too!!!!!!!!!!!
Yes, thanks Matthew, I really appreciate it!
I'll post the control as soon as I can find out where I downloaded it form K ?
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
www.vbweb.f9.co.uk
Is the address I mentioned that you can get the vbWebProgressBar From.
Thank you Electroman! Much appreciated.