Announcement

Collapse
No announcement yet.

Default Startup Module Name in VBScript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Default Startup Module Name in VBScript

    Quick question that I just can't seem to find a straight answer on...

    Is there a default first called module in VBScript akin to PBMAIN?

    I know you can have code outside of modules in VBScript but I was trying to determine if there was a default module name which would override/replace stuff that was outside of modules.
    Last edited by George Bleck; 9 Jul 2008, 10:28 AM.
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

  • #2
    Looking at MS documentation at http://msdn.microsoft.com/en-us/libr...7y(VS.85).aspx
    seems not.

    Comment


    • #3
      Aye, I had been reviewing that but there is nothing that points in either direction that I can find.

      I guess I just need to hear "there isn't one" as opposed to not knowing for sure. Programmers mind
      <b>George W. Bleck</b>
      <img src='http://www.blecktech.com/myemail.gif'>

      Comment


      • #4
        There is a way to define a default module in a class but i'm not working with classes in this case.
        <b>George W. Bleck</b>
        <img src='http://www.blecktech.com/myemail.gif'>

        Comment


        • #5
          Usually I do not like "absolute" convinction (there is always someone knowing more than me ) but if you prefer: there is no automatic executed function in VBScript!

          But yes, like you said, there is the constructor of a class that is invoked every time a new object of that class is created but you need to create an object of that class and release it at the end:

          Code:
          Function PBMain
             MsgBox("Hi there from PBMain")
          End Function
           
          Class MyMain
             '---Constructor
             Private Sub Class_Initialize
                PBMain
             End Sub
             '---Destructor
             'Private Sub Class_Terminate
             '   do something at the end
             'End Sub
          End Class
           
          Set MyApplication = New MyMain
          Set MyApplication = Nothing
          At this point it is more easy something like:
          Code:
          Function PBMain
             MsgBox("Hi there from PBMain")
          End Function
           
          Call PBMain
          Last edited by Eros Olmi; 9 Jul 2008, 10:52 PM.

          Comment


          • #6
            Thank Eros... needed that forceful nature
            <b>George W. Bleck</b>
            <img src='http://www.blecktech.com/myemail.gif'>

            Comment


            • #7
              As Eros said, there's no default startup procedure in VBScript. Therefore I always fake it by doing

              Code:
              ' Possible declarations
              Dim ....
              
              ' First executing code line
              Call Main()
              
              Sub Main()
              
              End Sub
              
              ' Other procedures follow if needed and are called from within Sub Main

              Comment

              Working...
              X