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

Need help with forms.

P: 1
I am currently trying to program a game with multiple forms. As of now I have it hide the main form that loads when the program is executed. I am having difficulties getting this form to be unhidden when the user clicks the button to return to the main form. Here is snippets of the code i have so far:
Main Form
Me.Hide()
Dim Set1 As New Set1
Set1.ShowDialog()
That part works fine. The main form is hidden and they can use Set1 correctly.
Here is where the problem comes in...
Set1
Me.Close()
Form1.ShowDialog()

The main form is called Form1 in design and it tells me, "Reference to a non-shared member requires an object referance."

Any help would be appreciated.
May 8 '07 #1
Share this Question
Share on Google+
2 Replies


P: 47
I am currently trying to program a game with multiple forms. As of now I have it hide the main form that loads when the program is executed. I am having difficulties getting this form to be unhidden when the user clicks the button to return to the main form. Here is snippets of the code i have so far:
Main Form
Me.Hide()
Dim Set1 As New Set1
Set1.ShowDialog()
That part works fine. The main form is hidden and they can use Set1 correctly.
Here is where the problem comes in...
Set1
Me.Close()
Form1.ShowDialog()

The main form is called Form1 in design and it tells me, "Reference to a non-shared member requires an object referance."

Any help would be appreciated.
in VB.NET everything treated as object.
So, when you call form1.showdialog() ,you do not create object for Form1. i.e why the error occur.
I just change the code. Please Check it.
Expand|Select|Wrap|Line Numbers
  1.        dim tmpMain as new Form1
  2.         tmpMain.ShowDialog()
  3.         Me.Close()
  4.  
if u r problem has been solved .then Plz make an End of Tag. Thank U.
May 8 '07 #2

Dököll
Expert 100+
P: 2,364
It looks like:

Expand|Select|Wrap|Line Numbers
  1. ....part of your code here
  2.  
  3. Unload Me
  4. Form1.Show
  5.  
  6. End
  7.  
  8.  
Should work here. Have you tried that?

Dököll
May 9 '07 #3

Post your reply

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