473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Closing form HELP!!!!!

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
4 1202
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
THEAF
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
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
Killer42
8,435 Expert 8TB
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

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

Similar topics

1
by: Uros | last post by:
When closing some forms in MSAccess 2003 Access is crashed (Microsoft Office Access has encounteres a problem and needs to close. We are sorry .......). If I close form without changes work OK, but...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
2
by: RobertK | last post by:
Hi i wonder how to avoid (trap) closing Form when user clicks 'X' button in right-top corner of the form. has anybody idea how to do it? thanks in advance. Regards, Robert
1
by: Cedric | last post by:
Hello, I have a form that could be closed by a code keyed or selected in a combobox but when I select my code my program end up with an error (NullReferenceException) and not when I keying the...
5
by: Mihailo | last post by:
I have two forms and that forms are connect with one button. When I click on Button in the first form, the second form will be open. But both form are open. I want when I click on the button to...
3
by: Darin | last post by:
I have a problem I just can't figure out. I have a form with a subform, and the recordsource of the subform has criteria based on some unbound fields in the parent form so that data in the parent...
0
by: faww | last post by:
i have been working with visual basic.net for about a year, ive actually managed to pass my teacher's knowledge of it, and he cant help me anymore with it. ive been designing a role playing game, and...
3
by: mtczx232 | last post by:
I have TabControls that Hold Forms on his TabPges (this make me easy to give ability to Designing each form in his IDE window). When form x is in middle of Edit Data Mode, I going to prevent:...
1
by: Salad | last post by:
I have a form that opens another (intermediary) form. The user selects an option on the intermediary form and it opens another form and the intermediary form is closed. Ex: From MainForm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.