the form that wont die...

Reply

Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

the form that wont die...

 
0
  #1
Nov 15th, 2008
This is a VB6 question.

I seem to have a problem with a form that should be unloading or at the very least become not visible. For whatever reason when another form is shown (form2.Show as an example) or made visible (Form2.Visible = True, next line would say Unload Form1 for instance), that same form (Form1) will come back up, including any message boxes as well... I quit them 2ce (sometimes 3 times) and they will finally go away for good.

It seems that on the first form in the code, even after the next form called is loaded, the code is re-read again even though i have definately unloaded it (it = the first form (Form1)).

Any ideas why this may be happening? This really is odd.

I will supply more code if needed.

thanks for any help.
Last edited by squidd; Nov 15th, 2008 at 10:25 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 13
Reputation: BigSeckC is an unknown quantity at this point 
Solved Threads: 0
BigSeckC's Avatar
BigSeckC BigSeckC is offline Offline
Newbie Poster

Re: the form that wont die...

 
0
  #2
Nov 16th, 2008
A copy of the actual code would be nice... I'm learning myself and this is definitely issue that I foresee in my future.
I am who I am...I do what I do
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

Re: the form that wont die...

 
0
  #3
Nov 16th, 2008
ok BigSeckC,

Here is the code I am having an issue with at the moment.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If Len(pass) <> 0 And InStr(1, pass, "reset") = False Then
  2. frmVerify.Height = 2100
  3. Label2.Visible = True
  4. Command1.Enabled = False
  5. Command1.Caption = "Loading..."
  6. Pause 1.5
  7. Unload frmVerify
  8. frmenter.Visible = True
  9.  
  10. ElseIf InStr(1, pass, "reset") Then
  11. Unload frmVerify
  12. Form2.Show
  13. MsgBox "Your Password has been reset. Please make a new one now."
  14.  
  15. Else
  16. frmVerify.Height = 1910
  17. Command1.Visible = True
  18. frmenter.Visible = False
  19. End If
  20. 1:
  21. End Sub

Now as you can see a number of things can happen here. But if it calls for a password reset, then the message box comes up 2 more times after it is clicked out. If the frmenter form is called for, then after the correct password is entered, the password form does go away, but comes back over and over endlessly. The code for the frmenter click is below:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Command1_Click()
  2. Dim pass As String
  3. On Error GoTo program
  4.  
  5. Open "C:\test.tst" For Input As #1
  6. Input #1, pass
  7. Close #1
  8. If Text1.Text = pass Then
  9. frmenter.Visible = False
  10. Form3.Show
  11.  
  12. Else
  13. enter = MsgBox("Incorrect Password", vbError, "Error")
  14. End If
  15. Exit Sub
  16. program:
  17. Open "c:\test.tst" For Output As #1
  18. Write #1, "reset"
  19. Close #1
  20. End Sub

I cant figure out why this is happening. The only thing i have found that will stop frmenter from coming back is to add 'vbModal' to the form3 that is called from form2 in the code directly above. I do not like using that however, as it isnt really solving the problem.

Any help would definately be appreciated.
Last edited by squidd; Nov 16th, 2008 at 5:00 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 13
Reputation: BigSeckC is an unknown quantity at this point 
Solved Threads: 0
BigSeckC's Avatar
BigSeckC BigSeckC is offline Offline
Newbie Poster

Re: the form that wont die...

 
0
  #4
Nov 17th, 2008
Ok... time to state the obvious... it's Looping the code.

Would a 'Do...While' help in this situation? I'm asking this as a general question to anyone...

Seems like that 'could/would' work - but I'm not proficient enough to say 'do this'.

Have you tried googling a 'pw reset snippet'? I had to do that once and it did help me understand what I was doing wrong
I am who I am...I do what I do
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

Re: the form that wont die...

 
0
  #5
Nov 18th, 2008
no i havent looked for that.. I will do it now. I know its looping the code, but i dont know why, obviously... hehe. thanks for the help.. ill check it out.

also, Im not sure how a Do While statement would help as that is a type of looping in itself. If Then isnt supposed to loop at all. That is what is so odd to me about this. It goes back to this code no matter what I do. Im sure that solution is fairly simple, yet it it isnt obvious to me, yet.

Thanks again.
Last edited by squidd; Nov 18th, 2008 at 9:03 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 13
Reputation: BigSeckC is an unknown quantity at this point 
Solved Threads: 0
BigSeckC's Avatar
BigSeckC BigSeckC is offline Offline
Newbie Poster

Re: the form that wont die...

 
0
  #6
Nov 18th, 2008
I know - it's truly weird - the reasoning behind the Do..While is:

"technically" if the code is "looping" without being told to, a Do...While 'should', in effect, negate the situation. (e.g., Do this - While that - Then Quit)

The only other things I can think of would be:

1. Run the program on another box - "maybe"there is 'something' on the code box that is causing the anomaly. (e.g., bad memory address, bad spot on HDD, etc.)

2. Re-write the code using a New Form and Test with each New Line - maybe even on a different box - 1 of 2 reasons...

A. The existing file could be corrupted. <-- not entirely impossible.

B. In testing each line, you would be narrowing down where 'the loop' is coming into play.

...right now, it's honestly the only things I can think of.

*crosses fingers for a corrupted file...

Not to insult your intelligence, but by box - I mean computer. Just in case someone else was wondering...

...why do I have this sneaky feeling I'm gonna run into this too?...
Last edited by BigSeckC; Nov 18th, 2008 at 8:35 pm.
I am who I am...I do what I do
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 13
Reputation: BigSeckC is an unknown quantity at this point 
Solved Threads: 0
BigSeckC's Avatar
BigSeckC BigSeckC is offline Offline
Newbie Poster

Re: the form that wont die...

 
0
  #7
Nov 18th, 2008
Just looking at the code again...

What procedure is tied to '1:'?

  1. End If
  2. 1:
  3. End Sub

...maybe there is something there...
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,080
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 124
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: the form that wont die...

 
0
  #8
Nov 20th, 2008
what is that PAUSE in your code ?
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 29
Reputation: arghasen is an unknown quantity at this point 
Solved Threads: 4
arghasen arghasen is offline Offline
Light Poster

Re: the form that wont die...

 
0
  #9
Nov 20th, 2008
do a thing ..................
use the unload command after the
frmenter.Visible = True
line.
the error u describe is just the opposte of waht it shold be withthis code.so just tey that..
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 13
Reputation: BigSeckC is an unknown quantity at this point 
Solved Threads: 0
BigSeckC's Avatar
BigSeckC BigSeckC is offline Offline
Newbie Poster

Re: the form that wont die...

 
0
  #10
Nov 20th, 2008
Originally Posted by debasisdas View Post
what is that PAUSE in your code ?

I'm assuming that the program is being told to wait 1.5 seconds before continuing. Is 'pause' not a valid command?

It makes sense 'logically'...but if it's not a command - it's not a command.
Last edited by BigSeckC; Nov 20th, 2008 at 9:20 pm. Reason: missed the "?"
I am who I am...I do what I do
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC