Inconsistent compile error

Discussion in 'Beta Versions' started by agraham, Aug 27, 2008.

  1. agraham

    agraham Expert Licensed User

    Code:
    -------------
    Module 
    "Main"
    -------------

    Sub Globals
       
    'Declare the global variables here.
    End Sub

    Sub App_Start
       Form1.Show
    End Sub

    Sub test
       
    Msgbox("Main")
    End Sub

    ------------
    Module 
    "Test"
    ------------
    Sub Globals
       
    'Declare the global variables here.
    End Sub

    Public Sub test
       
    Msgbox("Test")
    End Sub
    I know that this is probably caused by having a Sub the same name as a Module but the behaviour seems inconsistent to me.

    If I have two Subs named "test" in the two modules I get a duplicate key compile error when I run it in the IDE.

    If I only have one Sub named "test" in either of the modules I don't get the compile error.

    If I change the names to both "test1" then I don't get a compile error.

    So why can I have one Sub named the same as a module but not two? I would expect either none, or as many as I have modules.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Thank you again. It will be fixed.
    You can't name a sub and a module with the same name. The error will show for the first duplicate name.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice