MACRO LIBRARY

IUserProgressBar demo

Free public access. No account or subscription required.

Files

IUserProgressBar demo

Code

Module: mMain

'Demonstrates how to use the progress bar and status bar.
    
'Preconditions: None.
'Results:
'1. The status bar text is changed. (Located on the right side.)
'2. The progress bar can be incremented and reset using the form.
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Sub main()
    UserForm1.Show
End Sub

User Form: UserForm1

Dim swPb As UserProgressBar
Dim swSbp As StatusBarPane 'Must be declared at class level
Dim swPbVal As Integer
Const PB_INCREMENT As Integer = 10
    
Private Sub cmdIncrement_Click()
    If swPbVal < 100 Then
        swPbVal = swPbVal + PB_INCREMENT
        swPb.UpdateProgress swPbVal
        swPb.UpdateTitle CreateTitle
    Else
        MsgBox "Progress complete!"
    End If
End Sub
    
Private Sub cmdReset_Click()
    StartPb
End Sub
    
Private Sub cmdUpdate_Click()
    swSbp.Text = txtStatusBarText.Text
End Sub
    
Private Sub UserForm_Initialize()
    Dim swApp As SldWorks.SldWorks
    Set swApp = Application.SldWorks
    
    Dim swFrame As Frame
    Set swFrame = swApp.Frame
    Set swSbp = swFrame.GetStatusBarPane
    
    swApp.GetUserProgressBar swPb
    swPbVal = 0
    StartPb
End Sub
    
Private Sub StartPb()
    swPb.End
    swPbVal = 0
    swPb.Start 0, 100, CreateTitle
End Sub
    
Private Function CreateTitle() As String
    CreateTitle = "Calculating... " & swPbVal & "%"
End Function