Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:18:47+00:00 2026-05-14T23:18:47+00:00

Hello i Have a programa that has starts in a main sub, it executes

  • 0

Hello i Have a programa that has starts in a main sub, it executes some code and after that code it opens a form using

System.Windows.Forms.Application.Run(General)

General is a form but also a class, so I wonder what it the pros or cons of using :

System.Windows.Forms.Application.Run(General)

vs

Dim gen as general
System.Windows.Forms.Application.Run(gen)

In the first I am opening a form using the name of the class, and I read that it is best to declare the instance as an object variable.

So far I used the first approach without any problem.

Thanks for your comments !

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:18:48+00:00Added an answer on May 14, 2026 at 11:18 pm

    Yes, your first code snippet gives OOP purists the shivers. Application.Run() requires a form object, you are passing the form type. That this is possible is an anachronism carried over from VB6. It is admittedly very bad style, it prevents programmers from understanding the difference between a type and an object. Something that’s crucial to understand to get ahead with object oriented programming. It is also quite lethal when you start using threads.

    Your second snippet is closer to what’s needed, except that it cannot work. You pass an uninitialized object to Run(). Fix:

    Dim gen as General = New General()
    System.Windows.Forms.Application.Run(gen)
    

    Or taking advantage of VB.NET syntax:

    Dim gen as New General
    System.Windows.Forms.Application.Run(gen)
    

    Or since you never actually need the object in the Main method:

    System.Windows.Forms.Application.Run(New General())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello I have my code that connects to my ftp server $conn_id = ftp_connect($ftp_server);
I'd like to have an argument to my program that has some required parameters
Hello: I am developing an application that has a lot of support dll's. some
I have Hello World code that uses function fhi from another hi.cpp file that
Hello i'm a new coder to android. I have a program that Plays Pauses
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
I have following simple program: import std.stdio; int main(string[] argv) { writeln(Hello, world!); return
I have this problem when trying to run hello world program using android SDK.
I have a class Message that has a std::string as a data member, defined
I have a UIPickerView object that has five rows that a user can select.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.