By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Closing form HELP!!!!!

P: 52
hi im using this code for to show a loading/progress bar:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer2_Timer()
  2. '
  3. If frmLoading.Visible = True Then
  4. Else
  5. End If
  6. Bar.Width = Bar.Width + 60
  7. If Bar.Width >= 1143 Then
  8.     Label2.Caption = "25%"
  9. End If
  10. If Bar.Width >= 2285 Then
  11.     Label2.Caption = "50%"
  12. End If
  13. If Bar.Width >= 3428 Then
  14.     Label2.Caption = "75%"
  15. End If
  16. If Bar.Width >= 4575 Then
  17.     frmLoading.Hide
  18.     frmLoading.Visible = True
  19.     frmStaff.Show
  20.     If Bar.Width <> 0 Then
  21.         Bar.Width = 135
  22.     End If
  23. End If
  24. End Sub
The code just moves a picture box to the right and changes % after a certain length. this window comes up when i click on a command button from another form. the code for that is a hide and show. the thing is that after the bar is finished loading it goes back to the previous form but it still runs so when it pops up again the bar will show where it is still running from.

i need a way to some how close it or something to start the code from the beginning fresh. i know the code may be simple so sorry.
AND THANK YOU.....
Jan 24 '08 #1
Share this Question
Share on Google+
4 Replies


P: 7
Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer2_Timer()
  2. 'If Form2.Visible = True Then
  3. 'Else
  4. 'End If
  5. bar.Width = bar.Width + 5
  6. If bar.Width >= 1143 Then
  7.     Label2.Caption = "25%"
  8. End If
  9. If bar.Width >= 2285 Then
  10.     Label2.Caption = "50%"
  11. End If
  12. If bar.Width >= 3428 Then
  13.     Label2.Caption = "75%"
  14. End If
  15. If bar.Width >= 4575 Then
  16.     Label2.Caption = "100%"
  17.     MsgBox ("done")
  18.     Form2.Hide
  19.     Form2.Visible = True     
  20.     Form3.Show
  21.     Timer2.Enabled = False
  22.     'If bar.Width = 0 Then
  23.     'bar.Width = 135
  24.     'End If
  25. End If
  26. End Sub
  27.  
You can comment form2.visible=true.
Jan 24 '08 #2

P: 52
don't understand what you mean.
i want it to start from the beginning when it loads again how can i do this.
Jan 24 '08 #3

P: 7
I think you have a frmstaff with a button, when you click n it goes to frmloading.
Which has a pic bar. When it finishes loading it returns back to frmstaff.

Is it so ?
Then try below code...
I have written the comment for 2 line in subroutine...
Go through it. I guess it'll work fine each time you load the page.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer2_Timer()
  2.  
  3. bar.Width = bar.Width + 5
  4.  
  5. If bar.Width >= 1143 Then
  6.     Label2.Caption = "25%"
  7. End If
  8.  
  9. If bar.Width >= 2285 Then
  10.     Label2.Caption = "50%"
  11. End If
  12.  
  13. If bar.Width >= 3428 Then
  14.     Label2.Caption = "75%"
  15. End If
  16.  
  17. If bar.Width >= 4575 Then
  18.     Label2.Caption = "100%"
  19.     MsgBox ("done")
  20.     Frmloading.Hide 
  21.     'Frmloading.Visible = True
  22.     frmstaff.Show
  23.     Timer2.Enabled = False                    ' stops the timer
  24.     bar.Width = 135                                ' initialize the bar width
  25.     ' Label2.Caption = " "
  26. End If
  27.  
  28. End Sub
Also reset the timer2 interval as 1.
Jan 27 '08 #4

Expert 5K+
P: 8,434
I think all that's required is to unload the form (not just hide it) when finished with it. Next time it is loaded, everything it contains will be reinitialised.
Jan 27 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.