DOCUMENT:Q191693 24-AUG-1998 [vbwin] TITLE :BUG: Ambiguous Name Detection for Private Functions Named "Main" PRODUCT :Microsoft Visual Basic for Windows PROD/VER: OPER/SYS:WINDOWS KEYWORDS: ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0 --------------------------------------------------------------------- SYMPTOMS ======== When a Visual Basic project contains two or more functions named "Main" (but only one is Public) and Sub Main is set as the Startup Object, the following error is received when the Project is compiled or run: "Ambiguous name detected: main" CAUSE ===== In addition to Public functions, Visual Basic also searches for Private functions for any name conflict. STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- 1. Create a new Standard EXE project in Visual Basic. Form1 is created by default. 2. Select Project Properties from the Project menu. 3. Change the Startup Object to Sub Main. 4. Add two code modules to the Project by choosing Add Module from the Project menu twice. 5. Paste the following code in the code window of Module1: Public Sub Main Msgbox "Hello" End Sub 6. Paste the following code in the code window of Module2: Private Sub Main Msgbox "Hi" End Sub 7. Press the F5 key to run the project. Note that the following error message is received: "Ambiguous name detected: main" Additional query words: kbDSupport kbVBp600bug kbCompiler kbdss kbVBp ====================================================================== Platform : WINDOWS Issue type : kbbug Solution Type : kbpending ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1998.