FIX: Sub Main Does Not Transfer Control to Form

ID: 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 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 kbWinCE kbWinCE100 kbGrpVB 
Version           : WINDOWS:1.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: March 3, 1999