Results 1 to 2 of 2

Thread: Displaying windows forms from a module

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    36

    Displaying windows forms from a module

    I am trying to display forms from a module with this code:

    Public Sub Main()
    Dim SomeForm as New Form()
    Dim SomeOtherForm as New Form()

    SomeForm.Show()
    SomeOtherForm.Show()
    End Sub

    The forms display (very) briefly, then vanish. My program then ends, and control is returned to the IDE. I have tried using the .ShowDialog method to make the forms persist (makes them modal), but of course then the problem is that you cannot display both forms concurrently. What am I doing wrong here? In VB6, once you loaded and showed forms, they would persist until closed.

    --Steve K.
    [email protected]

  2. #2
    Tygur
    Guest
    Basically, your app ends when Main stops running. What you have to do is put a line that looks something like this at the end:
    Application.Run(FormVariableName)

    ..where FormVariableName is the name of a variable that references your main form. I don't have VB.NET here, so I might've gotten the name of the class wrong. It looks right, tho.

Posting Permissions

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



Click Here to Expand Forum to Full Width