Results 1 to 3 of 3

Thread: Open a windows form

  1. #1
    philiop is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    May 2010
    Posts
    22
    Reputation
    40

    Open a windows form

    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 by philiop; 05-06-2010 at 7:18 AM.

  2. #2
    demausdauth is offline VB.NET Forum Master
    .NET Framework
    .NET 2.0
    Join Date
    Mar 2008
    Location
    Minnesota
    Posts
    281
    Reputation
    275
    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.

    Code:
    'Create the instance
    Dim myInstance as New form1
    
    'Do something with the instance
    myInstance.Show()
    If someone has helped you please rate them.

  3. #3
    philiop is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    May 2010
    Posts
    22
    Reputation
    40
    Your an absolute star. Thank you

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking