?
Solved

load form

Posted on 2005-02-25
5
Medium Priority
?
210 Views
Last Modified: 2010-04-23
I've looked everywhere in the Help file but such a simple question I can't find.

In VB6
Sub Main()
Form1.Show
End Sub

in VB7, I got this far
Imports System.Windows.Form

Sub Main()
Dim f as New Form1
f.Show
End Sub

and it does, but then the End Sub stops the app.
Why?
0
Comment
Question by:broadbent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13405699
Sub Main
    Application.Run(New Form1)
End Sub
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13405739
Also take a look at the techniques I present in this PAQ for switching between forms:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21274481.html

They make use of the ApplicationContext() class:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsapplicationcontextmemberstopic.asp

Also, if you don't need main, then change your Project properties to start with Form1 instead.

~IM
0
 
LVL 4

Author Comment

by:broadbent
ID: 13406815
Thanks, but Form1 is not defined. How do I do this?
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 150 total points
ID: 13407039
>> Form1 is not defined.

Eh?!

>> Sub Main()
>> Dim f as New Form1
>> f.Show
>> End Sub

>> and it does, but then the End Sub stops the app.

You said in your original description that the code works...so you must have a Form1 defined or it wouldn't compile.

Go to Project --> Properties and change the "Output Type" from "Console Application" to "Windows Application".  If you need a form in your project then go to Project --> Add Windows Form.

~IM
0
 
LVL 4

Author Comment

by:broadbent
ID: 13409690
I was looking for wrong name!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question