943,691 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Nov 15th, 2008
0

the form that wont die...

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster
squidd is offline Offline
100 posts
since Nov 2007
Nov 16th, 2008
0

Re: the form that wont die...

A copy of the actual code would be nice... I'm learning myself and this is definitely issue that I foresee in my future.
Reputation Points: 12
Solved Threads: 0
Newbie Poster
BigSeckC is offline Offline
13 posts
since Nov 2008
Nov 16th, 2008
0

Re: the form that wont die...

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.
Reputation Points: 10
Solved Threads: 2
Junior Poster
squidd is offline Offline
100 posts
since Nov 2007
Nov 17th, 2008
0

Re: the form that wont die...

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
Reputation Points: 12
Solved Threads: 0
Newbie Poster
BigSeckC is offline Offline
13 posts
since Nov 2008
Nov 18th, 2008
0

Re: the form that wont die...

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.
Reputation Points: 10
Solved Threads: 2
Junior Poster
squidd is offline Offline
100 posts
since Nov 2007
Nov 18th, 2008
0

Re: the form that wont die...

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.
Reputation Points: 12
Solved Threads: 0
Newbie Poster
BigSeckC is offline Offline
13 posts
since Nov 2008
Nov 18th, 2008
0

Re: the form that wont die...

Just looking at the code again...

What procedure is tied to '1:'?

vb Syntax (Toggle Plain Text)
  1. End If
  2. 1:
  3. End Sub

...maybe there is something there...
Reputation Points: 12
Solved Threads: 0
Newbie Poster
BigSeckC is offline Offline
13 posts
since Nov 2008
Nov 20th, 2008
0

Re: the form that wont die...

what is that PAUSE in your code ?
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Nov 20th, 2008
0

Re: the form that wont die...

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..
Reputation Points: 10
Solved Threads: 5
Light Poster
arghasen is offline Offline
35 posts
since Nov 2008
Nov 20th, 2008
0

Re: the form that wont die...

Click to Expand / Collapse  Quote originally posted by debasisdas ...
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 "?"
Reputation Points: 12
Solved Threads: 0
Newbie Poster
BigSeckC is offline Offline
13 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: using of Crviewer component.......
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: help me to fix my counter





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC