{"id":2146,"date":"2013-02-03T11:44:25","date_gmt":"2013-02-03T03:44:25","guid":{"rendered":"http:\/\/www.vbtutor.net\/index.php\/"},"modified":"2018-06-24T17:44:03","modified_gmt":"2018-06-24T09:44:03","slug":"visual-basic-2012-lesson-3-working-with-control-properties","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-3-working-with-control-properties\/","title":{"rendered":"Visual Basic 2012 Lesson 3-Working with Control Properties"},"content":{"rendered":"<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-2-working-with-controls\/\">[Lesson 2]<\/a>&lt;&lt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-tutorial\/\"> [CONTENTS] <\/a>&gt;&gt;<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-4-object-oriented-programming\/\"> [Lesson 4]<\/a><\/strong><\/h4>\n<h3>3.1 The Control Properties<\/h3>\n<p>All controls in Visual Basic 2012 IDE have properties. By altering the properties of a control, we are able\u00a0to customize its appearance and how it responds to an event. Basically, you can set the properties of the controls in the properties window of Visual Basic 2012 IDE at design time or at runtime. Figure 3.1 \u00a0is the typical properties window for a form. It refers particularly to the interface of the first application you have created in the previous lesson.<\/p>\n<p>In the properties window, the item appears at the top part is the object currently selected (in Figure 3.1, the object selected is Form1). At the bottom part, the items listed in the left column represent the names of various properties associated with the selected object while the items listed in the right column represent the states of the properties. Properties can be set by highlighting the items in the right column then change them by typing or selecting the options available.<\/p>\n<p>You may also alter other properties of a control such as font, location, size, foreground color, background color, MaximizeBox, MinimizeBox and etc. You can also change the properties of the object at runtime to give special effects such as change of color, shape, animation effect and so on.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif\" alt=\"\" width=\"307\" height=\"407\" \/><\/p>\n<p style=\"text-align: center;\"><strong>Figure 3.1<\/strong><\/p>\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<p><a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2013\/01\/vb2012-Fig2.5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignone 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<p style=\"text-align: center;\"><strong>Figure 3.2<\/strong><\/p>\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<h4>3.1.1 Customizing the Form<\/h4>\n<p>We can customize a form by changing the values in the properties window. First of all, let&#8217;s change the title of the form. The title of the form is defined by the Text property and its default name is Form 1. To change the form&#8217;s title to any name that you like, simply click in the box on the right of the Text property and type in the new name, in this example, the title is Addition Calculator. After this, you can notice that the form&#8217;s title will appear on top of the windows.<\/p>\n<p>In addition, we can customize the form&#8217;s color. The following code will change the form color to yellow every time the form is loaded. Visual Basic 2012 uses RGB(Red, Green, Blue) to determine the colors. The RGB code for yellow is 255,255,0 while\u00a0<strong>Me<\/strong> in the code refer to the current form and Backcolor is the property of the form&#8217;s background color. The formula to assign the RGB color to the form is <strong>Color.FormArbg(RGB code)<\/strong>. \u00a0The event procedure is as follows:<\/p>\n<pre style=\"font-size: 110%;\">Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles \r\n MyBase.Load\r\n Me.BackColor = Color.FromArgb(255, 0, 255)\r\nEnd Sub\r\nEnd Class\r\n<\/pre>\n<p>You may also use the following procedure to assign the color at runtime.<\/p>\n<pre style=\"font-size: 110%;\">Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load\r\nMe.BackColor = Color.Magenta\r\nEnd Sub\r\n<\/pre>\n<p>Both procedures above will load the form with a magenta background as follows:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.3.gif\" alt=\"\" width=\"300\" height=\"300\" \/><br \/>\nHere are some of the common colors and the corresponding RGB codes. You can always experiment with other combinations, but remember the maximum number for each color is 255 and the minimum number is 0.<\/p>\n<p><a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2012\/04\/colorcode.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1012\" title=\"colorcode\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2012\/04\/colorcode.jpg\" alt=\"\" width=\"976\" height=\"76\" srcset=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2012\/04\/colorcode.jpg 976w, https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2012\/04\/colorcode-300x23.jpg 300w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/a><\/p>\n<p>The following is another program that allows the user to enter the RGB codes into three different textboxes and when he or she clicks the display color button, the background color of the form will change according to the RGB codes. So, this program allows users to change the color properties of the form at runtime.<\/p>\n<p><center><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.4.gif\" alt=\"\" width=\"475\" height=\"300\" \/><\/center><\/p>\n<h4><strong>The code<\/strong><\/h4>\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 rgb1, rgb2, rgb3 As Integer\r\n rgb1 = TextBox1.Text\r\n rgb2 = TextBox2.Text\r\n rgb3 = TextBox3.Text\r\n Me.BackColor = Color.FromArgb(rgb1, rgb2, rgb3)\r\nEnd Sub\r\n<\/pre>\n<p><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=\"6598395509\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-2-working-with-controls\/\">[Lesson 2]<\/a>&lt;&lt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-tutorial\/\"> [CONTENTS] <\/a>&gt;&gt;<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-4-object-oriented-programming\/\"> [Lesson 4]<\/a><\/strong><\/h4>\n<p>*This article has been translated to <a href=\"http:\/\/science.webhostinggeeks.com\/visual-basic-2012\">Serbo-Croatian<\/a> language by Vera Djuraskovic from <a href=\"http:\/\/webhostinggeeks.com\/\">Webhostinggeeks.com<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 2]&lt;&lt;\u00a0 [CONTENTS] &gt;&gt; [Lesson 4] 3.1 The Control Properties All controls in Visual Basic 2012 IDE have properties. By altering the properties of a control, we are able\u00a0to customize its appearance and how it responds to an event. Basically, you can set the properties of the controls in the properties window of Visual Basic &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-3-working-with-control-properties\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2012 Lesson 3-Working with Control Properties<\/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-2146","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 3-Working with Control Properties - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB<\/title>\n<meta name=\"description\" content=\"This visual basic 2012 lesson shows you how to work with Control Properties 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_Lesson3.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 3-Working with Control Properties - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"og:description\" content=\"This visual basic 2012 lesson shows you how to work with Control Properties in visual basic 2012\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.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:44:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif\" \/>\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=\"3 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-3-working-with-control-properties\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html\",\"name\":\"Visual Basic 2012 Lesson 3-Working with Control Properties - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\",\"isPartOf\":{\"@id\":\"https:\/\/www.vbtutor.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif\",\"datePublished\":\"2013-02-03T03:44:25+00:00\",\"dateModified\":\"2018-06-24T09:44:03+00:00\",\"description\":\"This visual basic 2012 lesson shows you how to work with Control Properties in visual basic 2012\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#primaryimage\",\"url\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif\",\"contentUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2012 Lesson 3-Working with Control Properties\"}]},{\"@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 3-Working with Control Properties - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"This visual basic 2012 lesson shows you how to work with Control Properties 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_Lesson3.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2012 Lesson 3-Working with Control Properties - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"This visual basic 2012 lesson shows you how to work with Control Properties in visual basic 2012","og_url":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.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:44:03+00:00","og_image":[{"url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@liewvk","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2012-lesson-3-working-with-control-properties\/","url":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html","name":"Visual Basic 2012 Lesson 3-Working with Control Properties - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","isPartOf":{"@id":"https:\/\/www.vbtutor.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif","datePublished":"2013-02-03T03:44:25+00:00","dateModified":"2018-06-24T09:44:03+00:00","description":"This visual basic 2012 lesson shows you how to work with Control Properties in visual basic 2012","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#primaryimage","url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif","contentUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif"},{"@type":"BreadcrumbList","@id":"http:\/\/www.vbtutor.net\/vb2012\/vb2012_Lesson3.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2012 Lesson 3-Working with Control Properties"}]},{"@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\/2146","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=2146"}],"version-history":[{"count":64,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2146\/revisions"}],"predecessor-version":[{"id":13095,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/2146\/revisions\/13095"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=2146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=2146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=2146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}