{"id":2074,"date":"2013-01-15T18:01:43","date_gmt":"2013-01-15T10:01:43","guid":{"rendered":"http:\/\/www.vbtutor.net\/index.php\/"},"modified":"2018-06-24T17:40:31","modified_gmt":"2018-06-24T09:40:31","slug":"visual-basic-2012-lesson-2-working-with-controls","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-2-working-with-controls\/","title":{"rendered":"Visual Basic 2012 Lesson 2-Working with Controls"},"content":{"rendered":"<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-1-introduction\/\">[Lesson 1]<\/a>&lt;&lt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-tutorial\/\">[CONTENTS]<\/a> &gt;&gt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-3-working-with-control-properties\/\">[Lesson 3]<\/a><\/strong><\/h4>\n<h3>2.1 What are Controls<\/h3>\n<p>Controls in Visual Basic 2012 are objects that can be placed on the form to perform various tasks. Figure 2.1 shows the toolbox that contains the controls. They are categorized into Common Controls, Containers, Menus, Toolbars, Data, Components, Printings and Dialogs. At the moment, we will focus on the common controls. Some frequently used common controls are Button, Label, ComboBox, ListBox, PictureBox, and TextBox. To insert a control into your form in Visual Basic 2012 IDE, drag the control from the toolbox and drop it onto the form. You can reposition and resize it as you like.<br \/>\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"1777484012\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<p><img decoding=\"async\" class=\"alignnone\" title=\"VB2012 Toolbox\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg\" alt=\"\" width=\"60%\" height=\"60%\" \/><\/p>\n<h4>Figure 2.1: Toolbox<\/h4>\n<p>&nbsp;<\/p>\n<p>When you click on the Toolbox tab, the common controls Toolbox will appear.<br \/>\n<a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2112\" title=\"vb2012 Fig2.2\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.2.jpg\" alt=\"\" width=\"1088\" height=\"884\" \/><\/a><\/p>\n<h4>Figure 2.2<\/h4>\n<h3>2.2 Creating Your First Application<\/h3>\n<p>To create your first application in Visual Basic 2012, drag the button control into the form, and change its default Text Button1 to OK in the properties window, the word OK will appear on the button in the form, as shown below:<\/p>\n<p><a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/Vb2012-Fig-2.3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2115\" title=\"Vb2012 Fig 2.3\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/Vb2012-Fig-2.3.jpg\" alt=\"\" width=\"914\" height=\"618\" \/><\/a><\/p>\n<h4>Figure 2.3<\/h4>\n<p>Now click on the OK button and the code window appears. Enter the code as follows:<\/p>\n<p><span style=\"color: #444444;\"><a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.31.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2124\" title=\"vb2012 Fig2.3\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.31.jpg\" alt=\"\" width=\"830\" height=\"386\" \/><\/a><br \/>\n<\/span><\/p>\n<h4>Figure 2.4<\/h4>\n<p>When you run the program and click on the OK button, a dialog box will appear and displays the \u201cWELCOME TO VISUAL BASIC 2012\u2033 message, as shown in the Figure below. The argument Title: is to assign the title of the dialog box.:<\/p>\n<p><a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.4.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2123\" title=\"vb2012 Fig2.4\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.4.jpg\" alt=\"\" width=\"240\" height=\"154\" \/><\/a><\/p>\n<h4 align=\"center\">Figure 2.5<\/h4>\n<h3>2.3 Using the Text Box<\/h3>\n<p>Next, we will show you how to create a simple calculator that adds two numbers using the TextBox control. In this program, you insert two text boxes, three labels, and one button. The two text boxes are for the users to enter two numbers, one label is to display the addition operator and the other label is to display the equal sign. The last label is to display the answer. Now change the label on the button to Calculate, then click on this button and enter the following code:<\/p>\n<pre style=\"font-size: 110%;\">Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\r\nDim num1, num2, product As Single\r\n num1 = TextBox1.Text\r\n num2 = TextBox2.Text\r\n product = num1 + num2\r\n Label1.Text = product\r\nEnd Sub\r\n<\/pre>\n<p>When you run the program and enter two numbers, pressing the calculate button adds the two numbers.<br \/>\n<a href=\"http:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2127\" title=\"vb2012 Fig2.5\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.5.jpg\" alt=\"\" width=\"346\" height=\"300\" \/><\/a><\/p>\n<h4 align=\"center\">Figure 2.6<\/h4>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"1777484012\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<div><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block;\" data-ad-format=\"autorelaxed\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"2306771905\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/div>\n<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-1-introduction\/\">[Lesson 1]<\/a>&lt;&lt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-tutorial\/\">[CONTENTS]<\/a> &gt;&gt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-3-working-with-control-properties\/\">[Lesson 3]<\/a><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 1]&lt;&lt;\u00a0[CONTENTS] &gt;&gt;\u00a0[Lesson 3] 2.1 What are Controls Controls in Visual Basic 2012 are objects that can be placed on the form to perform various tasks. Figure 2.1 shows the toolbox that contains the controls. They are categorized into Common Controls, Containers, Menus, Toolbars, Data, Components, Printings and Dialogs. At the moment, we will focus &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-2-working-with-controls\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2012 Lesson 2-Working with Controls<\/span><\/a><\/p>\n","protected":false},"author":23013,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-2074","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Visual Basic 2012 Lesson 2-Working with Controls in visual basic 2012<\/title>\n<meta name=\"description\" content=\"This Visual Basic 2012 lesson shows you how to work with controls in visual basic 2012\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Visual Basic 2012 Lesson 2-Working with Controls in visual basic 2012\" \/>\n<meta property=\"og:description\" content=\"This Visual Basic 2012 lesson shows you how to work with controls in visual basic 2012\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html\" \/>\n<meta property=\"og:site_name\" content=\"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Vbtutor\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-24T09:40:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@liewvk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-2-working-with-controls\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html\",\"name\":\"Visual Basic 2012 Lesson 2-Working with Controls in visual basic 2012\",\"isPartOf\":{\"@id\":\"https:\/\/www.vbtutor.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg\",\"datePublished\":\"2013-01-15T10:01:43+00:00\",\"dateModified\":\"2018-06-24T09:40:31+00:00\",\"description\":\"This Visual Basic 2012 lesson shows you how to work with controls in visual basic 2012\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#primaryimage\",\"url\":\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg\",\"contentUrl\":\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg\",\"width\":\"297\",\"height\":\"936\",\"caption\":\"Visual Basic 2012 toolbox\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2012 Lesson 2-Working with Controls\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vbtutor.net\/#website\",\"url\":\"https:\/\/www.vbtutor.net\/\",\"name\":\"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\",\"description\":\"Start learning Visual Basic from beginner to advanced. Includes VB.NET, VBA, and classic VB tutorials for students and professionals.\",\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Visual Basic 2012 Lesson 2-Working with Controls in visual basic 2012","description":"This Visual Basic 2012 lesson shows you how to work with controls in visual basic 2012","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2012 Lesson 2-Working with Controls in visual basic 2012","og_description":"This Visual Basic 2012 lesson shows you how to work with controls in visual basic 2012","og_url":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html","og_site_name":"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","article_publisher":"https:\/\/www.facebook.com\/Vbtutor","article_modified_time":"2018-06-24T09:40:31+00:00","og_image":[{"url":"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@liewvk","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-2-working-with-controls\/","url":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html","name":"Visual Basic 2012 Lesson 2-Working with Controls in visual basic 2012","isPartOf":{"@id":"https:\/\/www.vbtutor.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg","datePublished":"2013-01-15T10:01:43+00:00","dateModified":"2018-06-24T09:40:31+00:00","description":"This Visual Basic 2012 lesson shows you how to work with controls in visual basic 2012","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#primaryimage","url":"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg","contentUrl":"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012toolbox.jpg","width":"297","height":"936","caption":"Visual Basic 2012 toolbox"},{"@type":"BreadcrumbList","@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson2.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2012 Lesson 2-Working with Controls"}]},{"@type":"WebSite","@id":"https:\/\/www.vbtutor.net\/#website","url":"https:\/\/www.vbtutor.net\/","name":"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"Start learning Visual Basic from beginner to advanced. Includes VB.NET, VBA, and classic VB tutorials for students and professionals.","inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/users\/23013"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/comments?post=2074"}],"version-history":[{"count":68,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2074\/revisions"}],"predecessor-version":[{"id":13093,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2074\/revisions\/13093"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=2074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=2074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=2074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}