{"id":1002,"date":"2012-04-04T17:18:36","date_gmt":"2012-04-04T09:18:36","guid":{"rendered":"http:\/\/www.vbtutor.net\/index.php\/"},"modified":"2018-06-24T18:52:15","modified_gmt":"2018-06-24T10:52:15","slug":"visual-basic-2010-lesson-3","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-3\/","title":{"rendered":"Visual Basic 2010 Lesson 3-Working with Control Properties"},"content":{"rendered":"<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-2\/\">[Lesson 2]<\/a>&lt;&lt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-tutorial\/\"> [CONTENTS] <\/a>&gt;&gt;<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-4\/\"> [Lesson 4]<\/a><\/strong><\/h4>\n<h3>3.1 The Control Properties<\/h3>\n<p>After adding a control to the default form, \u00a0set certain properties for the control to determine its appearance and how should it behaves. You can set the properties of the controls in the properties window at design time or at runtime. Figure 3.1 is a typical properties window for a form in Visual Basic 2010 IDE:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif\" alt=\"visual basic 2010 ide\" width=\"307\" height=\"407\" \/><\/p>\n<h4><strong>Figure 3.1<\/strong><\/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=\"1723562988\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\nThe 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. Notice that the title will appear on top of the window. In the properties window, the item appears at the top part is the object currently selected (in Figure 3.2, 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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_2.1.gif\" alt=\"Visual Basic 2010\" width=\"313\" height=\"231\" \/><\/p>\n<h4><strong>Figure 3.2<\/strong><\/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=\"1723562988\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\nProperties can be set by highlighting the items in the right column then change them by typing or selecting the options available. You may also alter other properties of the form 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>For example, the following code will change the form color to yellow every time the form is loaded. Visual Basic 2010 uses RGB(Red, Green, Blue) to determine the colors. The RGB code for yellow is 255,255,0. Me 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\r\nPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 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\n Me.BackColor = Color.Magenta\r\nEnd Sub\r\n<\/pre>\n<p>Both procedures above will load the form with a magenta background as shown in Figure 3.3<\/p>\n<p>&nbsp;<\/p>\n<h4><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 \/>\n<strong>Figure 3.3<\/strong><\/h4>\n<p>Here 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=\"Visual Basic 2010\" 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><br \/>\n<strong>Figure 3.4<\/strong><\/p>\n<p>The following is another program that allows the user to enter the RGB codes into three different text boxes 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, as shown in Figure 3.5.<\/p>\n<h4><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.4.gif\" alt=\"Visual Basic 2010\" width=\"475\" height=\"300\" \/><br \/>\nFigure 3.5<\/h4>\n<p><strong>The code<\/strong><\/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 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<!-- vb2010 tutorial matched --><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block;\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"8075128701\" data-ad-format=\"autorelaxed\"><\/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-2010-lesson-2\/\">[Lesson 2]<\/a>&lt;&lt; <a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-tutorial\/\"> [CONTENTS] <\/a>&gt;&gt; <a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-4\/\">[Lesson 4]<\/a><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 2]&lt;&lt;\u00a0 [CONTENTS] &gt;&gt; [Lesson 4] 3.1 The Control Properties After adding a control to the default form, \u00a0set certain properties for the control to determine its appearance and how should it behaves. You can set the properties of the controls in the properties window at design time or at runtime. Figure 3.1 is a &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-3\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2010 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-1002","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 2010 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 2010 lessons teaches how to work with control properties\" \/>\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\/vb2010\/vb2010_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 2010 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 2010 lessons teaches how to work with control properties\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_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-24T10:52:15+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-2010-lesson-3\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_Lesson3.html\",\"name\":\"Visual Basic 2010 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\/vb2010\/vb2010_Lesson3.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_Lesson3.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif\",\"datePublished\":\"2012-04-04T09:18:36+00:00\",\"dateModified\":\"2018-06-24T10:52:15+00:00\",\"description\":\"This Visual Basic 2010 lessons teaches how to work with control properties\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_Lesson3.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_Lesson3.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_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\/vb2010\/vb2010_Lesson3.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2010 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 2010 Lesson 3-Working with Control Properties - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"This Visual Basic 2010 lessons teaches how to work with control properties","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\/vb2010\/vb2010_Lesson3.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2010 Lesson 3-Working with Control Properties - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"This Visual Basic 2010 lessons teaches how to work with control properties","og_url":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_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-24T10:52:15+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-2010-lesson-3\/","url":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_Lesson3.html","name":"Visual Basic 2010 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\/vb2010\/vb2010_Lesson3.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_Lesson3.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/vb2010_3.2.gif","datePublished":"2012-04-04T09:18:36+00:00","dateModified":"2018-06-24T10:52:15+00:00","description":"This Visual Basic 2010 lessons teaches how to work with control properties","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_Lesson3.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2010\/vb2010_Lesson3.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_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\/vb2010\/vb2010_Lesson3.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2010 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\/1002","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=1002"}],"version-history":[{"count":75,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/1002\/revisions"}],"predecessor-version":[{"id":13523,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/1002\/revisions\/13523"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=1002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=1002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=1002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}