?
Solved

Progressbar to track process

Posted on 2003-02-25
4
Medium Priority
?
236 Views
Last Modified: 2010-08-05
I wrote this procedure that performs multiple functions. After the user selects his/her name from a list box and clicks the command button on the form, the process verifies user authentication, move file from media into user's directory, rename files and some other things. i would like to show the progress of this whole process in a progressbar displayed in a statusbar.
Thanks in advance
sk
0
Comment
Question by:skhan22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Expert Comment

by:MUPPET
ID: 8015375
add the componant microsoft comman controls, place componant on form.

progressbar1.min = 0
progressbar1.max = 100

progressbar1.value = 10

your events

progressbar1.value = 20

etc
0
 
LVL 3

Accepted Solution

by:
sanjaykattimani earned 150 total points
ID: 8015796
progressbar1.value = 20
doevents
'authenticate the user
'....
progressbar1.value = 40
doevents
'move the media
'....
progressbar1.value = 60
doevents
'rename files
'....
progressbar1.value = 80
doevents
'do other things
'....

progressbar1.value = 100
doevents


Do events will make sure that it displays the status on screen. and write the code in between these comments. By default min is set to 0 and max is set to 100.

Hope that helps

0
 
LVL 1

Expert Comment

by:dmstrat
ID: 8020850
If you know how many process are in place you could use this simple process that I use for my applications.  You should modify it for your own use as this is a "training" application for progress bars only.  Also, set your max to the number of processes you are having to perform.  I also use three functions (not shown below) call ProgressBar_START(min,max,statusMessage), ProgressBar_Increment(newStatusMessage), and ProgressBar_END() that basically bring the progress bar to visible status, sets the min/max values, increments the progress bar as you work on predefined process, then makes the control (and possibly additional controls like what you are doing now labels) invisible.  

Lot's of options, but hopefully below will at least get you started with how to use a ProgressBar control.  Don't forget to reference the Common Controls Dialog to see the Progress Bar on the ToolBox.

Dan M.
dmstrat@yahoo.com

------------------------------------------------------


VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmProgressBar
   Caption         =   "Progress Bar Training"
   ClientHeight    =   3390
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7395
   LinkTopic       =   "Form1"
   ScaleHeight     =   3390
   ScaleWidth      =   7395
   StartUpPosition =   3  'Windows Default
   Begin VB.Timer Timer2
      Left            =   5400
      Top             =   0
   End
   Begin VB.TextBox Text3
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   5640
      TabIndex        =   5
      Text            =   "100"
      Top             =   2040
      Width           =   735
   End
   Begin VB.TextBox Text2
      Height          =   285
      Left            =   1200
      TabIndex        =   4
      Text            =   "0"
      Top             =   2040
      Width           =   855
   End
   Begin VB.TextBox Text1
      Height          =   285
      Left            =   3240
      TabIndex        =   2
      Text            =   "100"
      Top             =   120
      Width           =   1095
   End
   Begin MSComctlLib.ProgressBar ProgressBar1
      Height          =   735
      Left            =   1200
      TabIndex        =   1
      Top             =   1080
      Visible         =   0   'False
      Width           =   5175
      _ExtentX        =   9128
      _ExtentY        =   1296
      _Version        =   393216
      Appearance      =   1
   End
   Begin VB.CommandButton Command1
      Caption         =   "Run Progress Bar"
      Height          =   615
      Left            =   2880
      TabIndex        =   0
      Top             =   2400
      Width           =   1815
   End
   Begin VB.Label LabelTest
      Height          =   255
      Left            =   3240
      TabIndex        =   9
      Top             =   1800
      Width           =   975
   End
   Begin VB.Label LabelThing
      BorderStyle     =   1  'Fixed Single
      Height          =   495
      Left            =   6120
      TabIndex        =   8
      Top             =   0
      Width           =   1215
   End
   Begin VB.Label Label3
      Alignment       =   1  'Right Justify
      Caption         =   "Max"
      Height          =   255
      Left            =   4800
      TabIndex        =   7
      Top             =   2055
      Width           =   735
   End
   Begin VB.Label Label2
      Caption         =   "Min"
      Height          =   255
      Left            =   2160
      TabIndex        =   6
      Top             =   2055
      Width           =   855
   End
   Begin VB.Label Label1
      Alignment       =   2  'Center
      Caption         =   "Speed Interval in microseconds (1000 = 1 sec)"
      Height          =   495
      Left            =   2760
      TabIndex        =   3
      Top             =   480
      Width           =   2055
   End
End
Attribute VB_Name = "frmProgressBar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim intMin, intMax, intTimerInterval As Integer
Dim intDiff, intPosition As Integer
Dim blnCheck, blnEnable As Boolean

Private Sub Form_Load()
    blnCheck = False
    blnEnable = False
    Timer2.Interval = 100   ' Set Timer interval.
End Sub


Private Sub Timer2_Timer()
    LabelThing.Caption = Time   ' Update time display.
    LabelTest.Caption = "counter:" & intPosition
    If intPosition = intMax Then
      Timer2.Enabled = False
      intPosition = intMin
      ' hide progressbar
      ProgressBar1.Visible = False
      Exit Sub
    Else
      intPosition = intPosition + 1
      ProgressBar1.Value = intPosition
    End If
   
End Sub

Private Sub Command1_Click()
'assume the following variables can not be changed:
'---------------------------
intTimerInterval = CDec(Text1.Text)
intMin = CInt(Text2.Text)
intMax = CInt(Text3.Text)
'MsgBox "Min:" & intMin & "Max:" & intMax & "Interval:" & intTimerInterval

If intMax > intMin Then
    ProgressBar1.Max = intMax
    ProgressBar1.Min = intMin
    ProgressBar1.Visible = True
    intDiff = intMax - intMin
    intPosition = intMin
    ProgressBar1.Value = intPosition
    Timer2.Interval = Text1.Text 'intTimeInterval
    'Timer2.Interval = 100 ' intTimeInterval
    blnEnable = True
Else
    MsgBox "need max to be bigger than the min"
    blnEnable = False
End If
Timer2.Enabled = blnEnable
End Sub
=======================EOF==============================
0
 

Author Comment

by:skhan22
ID: 8021181
Thank you all of you for your suggestions and taking some timeout to answer my question.
thanks
sk
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question