FIX: Sub Main Does Not Transfer Control to Form

Q180528


The information in this article applies to:


SYMPTOMS

When a Windows CE project has a module with Sub Main set as the Startup Object, control of the application does not transfer to a form when the Sub Main is finished, causing the application to end prematurely.


RESOLUTION

Avoid using Sub Main as the Startup object. Use a form as the Startup object.


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products that are listed at the beginning of this article.

This problem was corrected in Window CE Toolkit for Visual Basic 6.0.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Windows CE Project in Visual Basic 5.0. Form1 is created by default.


  2. Add a new module to the project by selecting Add Module from the Project menu.


  3. Add the following code to Module1:
    
          Sub Main()
              Form1.Show
          End Sub 


  4. Select Project1 Properties from the Project menu.


  5. Set the Startup Object to Sub Main.


  6. Press the F5 key to run the project and note that the application will end when sub main execution is completed instead of passing control of the application to Form1.


© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Mike Dixon, Microsoft Corporation

Additional query words: wince vbce vbce5 vbce6

Keywords : kbToolkit kbVBp kbVBp500bug kbVBp600fix kbOSWinCEsearch kbOSWinCE100 kbGrpDSVB
Issue type : kbbug
Technology : kbVBSearch kbAudDeveloper kbWinCETKVBSearch kbWinCESearch kbWinCETK100VB500


Last Reviewed: October 21, 1999
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.