[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

Disadvantage of form created objects.

I am trying to learn "The right way" of programming in VB.NET. What I have noticed in the tutorials at Microsoft or LearnVisualStudio.com 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.
3 Solutions
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.
Mike TomlinsonMiddle School Assistant TeacherCommented:
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...
reefcrazedAuthor Commented:
But the form seems to generate much code that is not really needed right ? Does this slow things down greatly ?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

"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)

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now