Results 1 to 2 of 2

Thread: How to set Global Declaration, or how to set sub main as the startup form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2008
    Location
    Philippines
    Posts
    70

    How to set Global Declaration, or how to set sub main as the startup form

    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim adapt As New OleDb.OleDbDataAdapter
    Dim sql As String

    i want to declare the following in a module and set a sub main() in the module and call form1.show,

    but i cant set the submain as the startup form.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: How to set Global Declaration, or how to set sub main as the startup form

    Please use the radio buttons provided to specify your version in future.

    I assume that you are using VB 2005 or VB 2008, in which case you would have to disable the Application Framework to use a Main method as your entry point. The preferred alternative is to use the Startup event to do whatever you would normally do in a Main method.

    As for your plan to use a module for those variables, it could be forgiven, if not recommended, for the DataSet and OleDbConnection, but certainly not for the OleDbDataAdapter and the String.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width