Disadvantage of form created objects.

Posted on 2006-05-26
Last Modified: 2010-04-23
I am trying to learn "The right way" of programming in VB.NET. What I have noticed in the tutorials at Microsoft or is that most of the time they drag the objects to the form from the toolbar, such as grids, dataadapters, etc.

Now when on the forums and I ask questions, the code returned from the responding party normally has things created in code such as this.

Dim connection As SqlConnection = New SqlConnection("Secret text in here")
Dim command As SqlCommand = New SqlCommand("RETURNIT", connection)
Dim adapter As SqlDataAdapter = New SqlDataAdapter(command)
Dim table As DataTable = New DataTable
I want to learn the "right way" or even the way that will make my program cleaner and faster, whatever the best practice is.
Question by:reefcrazed
    LVL 9

    Assisted Solution

    I think it is more of a thing of 6 in one half dozen in the other. Probably you should just pick what is the quickest for you to perform. Some people write code faster than they can pop into the form designer and set the properties.
    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    Right...also when answering questions for other people, it sometimes easier to create everything in code so that you don't have to worry about what the name of the control on question askers Form is...

    Author Comment

    But the form seems to generate much code that is not really needed right ? Does this slow things down greatly ?
    LVL 44

    Accepted Solution

    "But the form seems to generate much code that is not really needed right ? Does this slow things down greatly ?"  

    No, the performance is not affected at all. (what's a few micro-seconds, here or there, amongst friends???  LOL)

    LVL 9

    Expert Comment

    I believe the points should be split between Arthur_Wood, Idle_Minds and Myself. We have all contributed to answering his question.

    Expert Comment

    I agree

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now