Create my own window

G

Gary Owsiany

Until now I have been using the default "windows application" template to
create a new window. What I would like to do is play with dynamic window
creation. However, when I just create a class that contains sub Main() it
doesn't want to compile in the IDE. Is there some property I need to set?
The code below is what I want to use to create my window class. How can I
do it within the VisualStudio IDE?
Thanks,
Gary O.

Public Shared Sub Main()

Dim form1 As New Form

Dim form2 As New Form

form1.Text = "Form passed to Run()"

form2.Text = "Second form"

form2.Show()

Application.Run(form1)

MessageBox.Show("Application.Run() has returned " & _

"control back to Main. Bye, Bye!", "Two Forms")

End Sub
 
A

Armin Zingler

Gary Owsiany said:
Until now I have been using the default "windows application"
template to create a new window. What I would like to do is play
with dynamic window creation. However, when I just create a class
that contains sub Main() it doesn't want to compile in the IDE.

Why? Error message? Which project type did you choose (Windowsapplication,
consoleapplicatoin or classlibrary)?
Is
there some property I need to set? The code below is what I want to
use to create my window class. How can I do it within the
VisualStudio IDE? Thanks,
Gary O.

Public Shared Sub Main()

Dim form1 As New Form

Dim form2 As New Form

form1.Text = "Form passed to Run()"

form2.Text = "Second form"

form2.Show()

Application.Run(form1)

MessageBox.Show("Application.Run() has returned " & _

"control back to Main. Bye, Bye!", "Two Forms")

End Sub

The code looks fine. What did you choose as the startup object in the
project properties?
 
H

Herfried K. Wagner [MVP]

* "Gary Owsiany said:
Until now I have been using the default "windows application" template to
create a new window. What I would like to do is play with dynamic window
creation. However, when I just create a class that contains sub Main() it
doesn't want to compile in the IDE. Is there some property I need to set?
The code below is what I want to use to create my window class. How can I
do it within the VisualStudio IDE?

\\\
Public Class AppMain
///
Public Shared Sub Main()

Dim form1 As New Form

Dim form2 As New Form

form1.Text = "Form passed to Run()"

form2.Text = "Second form"

form2.Show()

Application.Run(form1)

MessageBox.Show("Application.Run() has returned " & _

"control back to Main. Bye, Bye!", "Two Forms")

End Sub

\\\
End Class
///

In the project properties dialog set 'AppMain' as startup object.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top