Open a windows form

philiop

Member
Joined
May 6, 2010
Messages
22
Programming Experience
Beginner
Hi,

I am relatively new to programming so this may sound dumb.

I previously made a small excel addin using visual basic. I have recently started trying to use visual studio and wanted to convert my addin into visual studio.

I am having difficulty in opening a windows form if its even possible. I added a windows form and tried to open in just using form1.show() and I am getting Reference to a Non Shared object requires an object reference

How do i resolve this or is it actually not possible?

Thanks in advance

Just realised i posted this in the wrong forum. Apologies. If anyone could move it would be fantastic :S
 
Last edited:
You need to work with a reference to the form not the form itself. When you create a new form in VS you are making the blueprint for a form. In your code you actually have to create an instance of what the blueprint represents then you can do stuff with it.

VB.NET:
Expand Collapse Copy
'Create the instance
Dim myInstance as New form1

'Do something with the instance
myInstance.Show()
 
Back
Top