Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progress bar while exiting

Status
Not open for further replies.

vmaruv

Programmer
Apr 8, 2002
102
US
Hi,

When I am exiting my form using the exit button, I am executing a batch file. Since this is taking time, I am using the vbHourglass to indicate that it is taking time.

But I would want to show a progress bar (initially not visible and later visible when the exit button is clicked) that the exit process is in progress.
How is this possible.

Can anyone help ?

Thanks in advance.
 
Or instead of a progress bar, is there anyother way. Like a message that displays "Exiting..." and exits once it is ready. Please someone suggest..
 
No Ideas ?? Please could someone suggest ??

your help is greatly appreciated.
 
You could have a label (visibility set to false) on the form saying "Exiting..." and then make it visible just before the batch file is executed and then the program would just shutdown as normal as it does now.

Harleyquinn

---------------------------------
For tsunami relief donations
 
Harleyquinn

Is it possible to have a message box sort of thing without a OK button that is displayed ? I tried to get help on this on the net but there is no message box without the OK button. Can you suggest something else for me ??

Thanks in Advance..
Vidya.
 
You can have a small border less form (with/out timer) to appear at the start of the code and dissappear at the end of the code.
I use it in a text editor that uses the MS Word spell checker. It appears with a timer and dissapear after the time.
Also it would be possible to use the progressbar how they use it with a webbrowser control.


Zameer Abdulla
Visit Me (New Look & style)
 
I did that, but it does not show the form. My code looks as below. Form1 is a bordless form with a lable "EITING..PLEASE WAIT". any idea why it does not showup ?

ask = MsgBox("Do You Really Want To Exit ", vbYesNo + vbExclamation, "EXIT")
If ask = 6 Then
Form1.Show
msg0 = "cd c:\"
msg1 = "set ROOT=" + root
msg2 = "set DATA=" + data
Open location For Output As #1
Print #1, msg0
Print #1, msg1
Print #1, msg2
Close #1
shell(location)
Endif
 
Hi,
I used Form1.show VbModal and now it is showing the form. But for some reason the code is hanging. It is taking too long to exit. Without the Form1.show VbModal it is taking just a few seconds.

Any idea why ?
 
i put have a timer in Form1 (the new form) and set the interval to 1 (is it 1 min or 1 sec ?) but in either case it is hanging..

Is it beacuse the control isnot coming back to the main form ?
 
hi Harleyquinn ...

if it is 1 millisecond..then I don't see why it should hang. Probably the control is going to Form1 and not returning to the main from to execute the next steps until it encounters a END statement to terminate the program.

Any clues regarding this ? your help is greatly appreciated.

Vidya.
 
I'm not used to timer control. pls. could u help ?

I'm setting the interval of the timer1 at design time as 0.
at run time I am doing the below. is this correct ?

ask = MsgBox("Do You Really Want To Exit ", vbYesNo + vbExclamation, "EXIT")
If ask = 6 Then
frmexit.Show vbModal
If frmexit.Timer1.Interval = 5000 Then
frmexit.Hide
End If

 
This way you will never exit from the "hang trap".
Code:
ask = MsgBox("Do You Really Want To Exit ", vbYesNo + vbExclamation, "EXIT")
             If ask = 6 Then                 
      with frmexit
		.Show vbModal              
		.Timer1.Interval = 5000
     end with                
     	 'The rest of work...        
	End If
Then in the frmexit's timer event add
Code:
Me.Hide

Zameer Abdulla
Visit Me (New Look & style)
 
If you setting the interval (the time between each execution of the timer) to 0 then the interval you are checking will never be 5000. Increment an integer value in the timer (i = i + 1) and check for the integer being 5000...

Harleyquinn

---------------------------------
For tsunami relief donations
 
Hi Zameer,

I tried doing exactly what you said in your above post. It does not help. The code is still hanging.

And I've also done as Harleyquinn said as below. not sure if it is correct..it does not help either !!

Thanks for being so patient !!

If ask = 6 Then
frmexit.Show vbModal
In timer1_Timer() I have given the code as below

Private Sub Timer1_Timer()
Dim i As Integer
i = 0
For i = 0 To 5000
i = 1 + 1
Next i
If i = 5000 Then
Me.Hide
End If
End Sub
 
I'm sure you've noticed that that doesn't really do it! The loop only takes microseconds to run, and the value gets reset on each call of the timer. The secret is to use Static instead of Dim which keeps its value between successive calls to the procedure. Try this: On a new form with just a Timer control and a Progressbar control, set the Timer interval to 50 and put this in the Timer event
Code:
Private Sub Timer1_Timer()
 Static lngProgress As Long  'retains its value
 lngProgress = lngProgress + 1
   If lngProgress = 100 Then
     Timer1.Enabled = False
     lngProgress = 0
     Me.Hide
   End If
 ProgressBar1.Value = lngProgress
End Sub

On your original form:
Code:
Private Sub cmdSave_Click()
Dim i as Integer
frmTimer.Show
For i = 1 to X 'however many elements to save
'********  Do your save bits here
DoEvents
Next i
End Sub

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top