Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

load form

Posted on 2005-02-25
5
Medium Priority
?
220 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
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

580 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