Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey, I have a wierd issue with my VB program.
The code for it is:
Me.Hide()
Form3.Show()

But this happens instead.. Link

The same form opens again instead of hiding and opening a new one. I don't know why is this happening because I have different form that uses the exact same code and it works perfectly.

What I have tried:

I tried to use an IF statement
If people = 0 Then
MsgBox("At least one person has to attend")
Else
Me.Hide()
Form3.Show()
Posted
Updated 2-Apr-18 17:06pm
Comments
[no name] 2-Apr-18 12:23pm    
Are you sure that "Me" and "Form3" are different forms?

Use the debugger: put a breakpoint on the line
VB
Me.Hide()
And run your app.
When it hits the breakpoint it will stop, and you can look at exactly what is going on.
Start by looking at Me and Form3 - if they are the same thing, then what you say is happening is exactly what I'd expect.

But calling your form variable "Form3" seems like a strange idea - given that "Form3" is the default name for a Visual Studio autogenerated Form class - so I'd also step into the methods and see if you have a Shared method called "Show" in your class as well.
This is assuming that your app compiles without problems - if there is no Shared Show method and that is a class name instead of a variable, then the EXE you are running may not look like that code!
 
Share this answer
 
I can see that the form is being reinitialized when relaunched. Hence it is a completely different instance of the form.

You should check the callstack when form appears second time. You will get the idea, from which function it is being launched.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900