Cannot create a new project that opens startup form

Have been using vb 2005 express final now for a week or too.  Have had no problems using and modifying example code and connecting to a MySQL database.  However i am now trying to create a new project and no matter what form is selected under startup form nothing displays when code f5 is pressed.  Message that build is ok in status bar screen refreshes and back to IDE.  However existing projects work ok.  Even creating a simple one form app leaving default form name as form1 the form will not display.  Any ideas please! 

 

step by step

1 new project windows app

2 add button to form

3 add code msgbox("Hello") to button1

4 verify form1 is startup object in properties

5 run ..............

nothing



Answer this question

Cannot create a new project that opens startup form

  • Mikael L

    That sounds like a bug to me. Main() should automatically be placed in an application project.

  • Kamesh Bora

    I just downloaded and installed VB Express and have the same problem. I have two machines at home that work fine with the Developer version.

    When I create a new project in Express and run it, it just compiles and closes right out, the form is never displayed. If I create a new project in Developer, it compiles and runs and shows the form and all is well. I thought I was going crazy.

    If I put a messagebox in Express and run it the messagebox is displayed but the form never shows up and the program just closes down immediately. I dont get any error messages, nothing to indicate the program terminated abnormally. You can step through the program and watch it run through the form_load but it is never displayed on the screen and still closes right away.

    Is there some difference with Express that I need to actually tell the program not to stop running as soon as it starts Or to get the form to actually display by default It all seems to work fine in Developer, but Express has issues.


  • Harley

    Ed, if the project you choose as your startup project has a Main entry defined then it will run. But if it does not, it won't. Every application requires an entry point. If you don't have one, your application doesn't start. One of the class files in the startup project has to contain this entry point. This has always been the case.



  • lianaent

    Now you guys have me really confused.  My projects run fine by opening the form I specify to load on startup, and the .load code executes fine.  I cannot find any reference to a Main sub in the code anywhere.

    When/why is it now necessary to code a Main() routine

     

      Ed Tenholder


  • Wit Hasie

    Do you only have one project in your solution Does the start-up project have a valid Main() entry defined

  • paul ashfield2006

    Yup, that 'main' thing is confusing: there is no 'main' subroutine in the form.

    I'd be interested to know as to how this has actually been solved. Forms don't have a 'main' routine, ordinarily. Class files don't require a 'main' subroutine. Does the origional posters application just 'quit' when run, or does it not show the form What is the startup object

    Can someone expound on this

    SJW



  • PA

    Yes only one project in my solution.

    Little lost on valid Main() entry........

     


  • caixiaoshan

    Sorry to here you are having the same problem. For some reason the sub main thing did fix my problems last night. However with the same code it is now back today. According to the documentation you only need a Sub Main if you dont use application framework and pick a startup form. 

    Unless somehow a template file or something has become corrupted on my system i would hope a patch would be available for this intersting feature.

    One thing that is different in my case is that i have been unable to get a message box to appear thru code from the form or anywhere else now that this is again not working

    So for the breakdown ......

    Last night adding the following to frmLogin worked

     

    Sub Main()

    Me.show()

    end sub

     

    Now it doesnt

    also have placed in module...  no better  


  • Mosquito

    Boba, what's your startup form By default it should be Form1, is this what you have

    SJW



  • Srinivasa D Parupalli

    Guess what original poster again.

    Adding a Main() to my frmlogin form last night did fix problem....

    But!!!! today it is back with the same code i saved last night

    My problem is identical to as described by gut who downloaded express and already had developer machines.  Except that now it has returned

    Searching for some direction here as it seems VB is crumbling underneath me


  • nesteroff

    Oh, I forgot this is the VB board. I'm not sure why you guys don't have a Main() method you can modify in VB!

  • SathishKumar

    Yes, I am just using the default form1. It doesnt matter if I add a control or just create a brand spanking new project and run it, it does the same thing every time. Just runs and drops right out of the thing. But like I said, I can put code in there and verify the form is actually loading and running but you cant see it on the screen and it just drops right back to the IDE without any user interaction. 

     

    I have tried putting a main() sub in there and it doesnt seem to make any difference.


  • kizelli

    Thank you for your help.  Sure enough i just slapped it in as a subroutine in the form selected as the start up form and it worked.

    Best reply i have ever recieved.


  • V4Venkat

    Check the Program.vb class file for a Main function/method. That's your "starting" point to run the application. If that's not there, nothing will happen.

  • Cannot create a new project that opens startup form