<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4375924187041747804</id><updated>2012-02-16T21:11:40.256+07:00</updated><title type='text'>Belajar Program VB</title><subtitle type='html'>Mari Belajar Bahasa Pemrograman Visual Basic</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-3414978533544043239</id><published>2011-05-21T10:04:00.004+07:00</published><updated>2011-05-21T10:43:11.791+07:00</updated><title type='text'>The Prisoner’s Dilemma – An Exercise in Inheritance</title><content type='html'>The prisoner's dilemma is a fundamental problem in game theory that demonstrates why two people might not cooperate even if it is in both their best interests to do so. It was originally framed by Merrill Flood and Melvin Dresher working at RAND in 1950. Albert W. Tucker formalized the game with prison sentence payoffs and gave it the "prisoner's dilemma" name (Poundstone, 1992).&lt;br /&gt;&lt;br /&gt;A classic example of the prisoner's dilemma (PD) is presented as follows:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Two suspects are arrested by the police. The police have insufficient evidence for a conviction, and, having separated the prisoners, visit each of them to offer the same deal. If one testifies for the prosecution against the other (defects) and the other remains silent (cooperates), the defector goes free and the silent accomplice receives the full one-year sentence. If both remain silent, both prisoners are sentenced to only one month in jail for a minor charge. If each betrays the other, each receives a three-month sentence. Each prisoner must choose to betray the other or to remain silent. Each one is assured that the other would not know about the betrayal before the end of the investigation. How should the prisoners act?&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;If we assume that each player cares only about minimizing his or her own time in jail, then the prisoner's dilemma forms a non-zero-sum game in which two players may each either cooperate with or defect from (betray) the other player. In this game, as in most game theory, the only concern of each individual player (prisoner) is maximizing his or her own payoff, without any concern for the other player's payoff. The unique equilibrium for this game is a Pareto-suboptimal solution, that is, rational choice leads the two players to both play defect, even though each player's individual reward would be greater if they both played cooperatively.&lt;br /&gt;&lt;br /&gt;In the classic form of this game, cooperating is strictly dominated by defecting, so that the only possible equilibrium for the game is for all players to defect. No matter what the other player does, one player will always gain a greater payoff by playing defect. Since in any situation playing defect is more beneficial than cooperating, all rational players will play defect, all things being equal.&lt;br /&gt;&lt;br /&gt;In the iterated prisoner's dilemma, the game is played repeatedly. Thus each player has an opportunity to punish the other player for previous non-cooperative play. If the number of steps is known by both players in advance, economic theory says that the two players should defect again and again, no matter how many times the game is played. However, this analysis fails to predict the behavior of human players in a real iterated prisoners dilemma situation, and it also fails to predict the optimum algorithm when computer programs play in a tournament. Only when the players play an indefinite or random number of times can cooperation be an equilibrium, technically a subgame perfect equilibrium meaning that both players defecting always remains an equilibrium and there are many other equilibrium outcomes. In this case, the incentive to defect can be overcome by the threat of punishment.&lt;br /&gt;&lt;br /&gt;In casual usage, the label "prisoner's dilemma" may be applied to situations not strictly matching the formal criteria of the classic or iterative games, for instance, those in which two entities could gain important benefits from cooperating or suffer from the failure to do so, but find it merely difficult or expensive, not necessarily impossible, to coordinate their activities to achieve cooperation.&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Strategy for the classic prisoner's dilemma&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-sE1jucuPVHk/TdcsipBsCRI/AAAAAAAAAKw/JbxsQvppCsg/s1600/GameTheory.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 208px;" src="http://4.bp.blogspot.com/-sE1jucuPVHk/TdcsipBsCRI/AAAAAAAAAKw/JbxsQvppCsg/s400/GameTheory.JPG" alt="" id="BLOGGER_PHOTO_ID_5609000834553350418" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-xo0gpmQIYno/TdctHLdbIAI/AAAAAAAAAK4/PwplSOAQHBo/s1600/GameTheory2.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 208px;" src="http://1.bp.blogspot.com/-xo0gpmQIYno/TdctHLdbIAI/AAAAAAAAAK4/PwplSOAQHBo/s400/GameTheory2.JPG" alt="" id="BLOGGER_PHOTO_ID_5609001462271778818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In "win-lose" terminology the table looks like this:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-ULg89QDHo2o/TdcwQ08zfcI/AAAAAAAAALA/fTyOWEHyGYU/s1600/PD1.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 103px;" src="http://4.bp.blogspot.com/-ULg89QDHo2o/TdcwQ08zfcI/AAAAAAAAALA/fTyOWEHyGYU/s400/PD1.JPG" alt="" id="BLOGGER_PHOTO_ID_5609004926562958786" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Imagine you are player A. If player B decides to stay silent about committing the crime then you are better off confessing, because then you will get off free. Similarly, if player B confesses then you will be better off confessing, since then you get a sentence of 3 months rather than a sentence of 1 year. From this point of view, regardless of what player B does, as player A you are better off confessing. One says that confessing (defecting) is the dominant strategy.&lt;br /&gt;&lt;br /&gt;As Prisoner A, you can accurately say, "No matter what Prisoner B does, I personally am better off confessing than staying silent. Therefore, for my own sake, I should confess." However, if the other player acts similarly then you both confess and both get a worse sentence than you would have gotten by both staying silent. That is, the seemingly rational self-interested decisions lead to worse sentences—hence the seeming dilemma. In game theory, this demonstrates that in a non-zero-sum game a Nash equilibrium need not be a Pareto optimum.&lt;br /&gt;&lt;br /&gt;Although they are not permitted to communicate, if the prisoners trust each other then they can both rationally choose to remain silent, lessening the penalty for both of them.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sumber:&lt;br /&gt;Book: Billy Hollis, 1999,  Visual Basic 6: Design, Specification and Objects, Prentice-Hall Series on Microsoft Technologies&lt;br /&gt;http://en.wikipedia.org/wiki/Prisoner's_dilemma&lt;br /&gt;http://www.iterated-prisoners-dilemma.net/&lt;br /&gt;http://www.lifl.fr/IPD/ipd.html.en&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-3414978533544043239?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/3414978533544043239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/05/prisoners-dilemma-exercise-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/3414978533544043239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/3414978533544043239'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/05/prisoners-dilemma-exercise-in.html' title='The Prisoner’s Dilemma – An Exercise in Inheritance'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-sE1jucuPVHk/TdcsipBsCRI/AAAAAAAAAKw/JbxsQvppCsg/s72-c/GameTheory.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-8688016543710750232</id><published>2011-05-04T19:52:00.002+07:00</published><updated>2011-05-04T19:55:25.536+07:00</updated><title type='text'>Controls Collection in VB6</title><content type='html'>The Controls Collection is a built-in collection belonging to a form and is maintained by Visual Basic. The Controls Collection contains references to all the controls on that form. Each member of the collection points to a different object on that form—for example, a TextBox, ComboBox, ListView, and so on.&lt;br /&gt;&lt;br /&gt;Each form in a project has its own Controls Collection that you can use to navigate through the different controls on a form. You can refer to each control within the collection as follows:&lt;br /&gt;&lt;br /&gt;Form.Controls(index)&lt;br /&gt;&lt;br /&gt;where Form is the form name, and Index is an integer value referring to the desired control. Since the Controls Collection is zero-based, Index values range from 0 up through a number that is one less than the total number of controls on the form. If you have 10 controls on a form, the Index values for the Controls Collection would range from 0 through 9.&lt;br /&gt;&lt;br /&gt;You will usually use in a Controls Collection when you need to process all the controls or the majority of the controls on a given form. You can loop through a Controls Collection either with a For Next loop, as in Prog 1, or with a For Each loop, as inProg 2.&lt;br /&gt;&lt;br /&gt;Prog 1&lt;br /&gt;LOOPING THROUGH A CONTROLS COLLECTION WITH A FOR NEXT LOOP&lt;br /&gt;For I = 0 To Form1.Controls.Count - 1&lt;br /&gt;' process Form1.Controls(I)&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;Prog 2&lt;br /&gt;LOOPING THROUGH A CONTROLS COLLECTION WITH A&lt;br /&gt;FOR EACH LOOP&lt;br /&gt;For Each obj In Form1. Controls&lt;br /&gt;' process obj&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;A common use of the Controls Collection is to clear all the controls on a form. If the user wants to reset all the fields on a data entry form, you can code a Clear button with code such as that found in Prog 3&lt;br /&gt;&lt;br /&gt;Prog 3&lt;br /&gt;CODE TO RESET ALL FIELDS ON A DATA ENTRY FORM&lt;br /&gt;&lt;br /&gt;Private Sub cmdClear_Click()&lt;br /&gt;Dim objControl As Control&lt;br /&gt;Dim sTemp As String&lt;br /&gt;For Each objControl In Me.Controls&lt;br /&gt;If TypeOf objControl Is TextBox Then&lt;br /&gt;' clear the text&lt;br /&gt;objControl.Text = ""&lt;br /&gt;ElseIf TypeOf objControl Is ComboBox Then&lt;br /&gt;' reset the listindex&lt;br /&gt;objControl.ListIndex = -1&lt;br /&gt;ElseIf TypeOf objControl Is Label Then&lt;br /&gt;' leave labels as is&lt;br /&gt;ElseIf TypeOf objControl Is CommandButton Then&lt;br /&gt;' leave commandbuttons as is&lt;br /&gt;ElseIf TypeOf objControl Is MaskEdBox Then&lt;br /&gt;' clear the masked edit control&lt;br /&gt;sTemp = objControl.Mask&lt;br /&gt;objControl.Mask = ""&lt;br /&gt;objControl.Text = ""&lt;br /&gt;objControl.Mask = sTemp&lt;br /&gt;Else&lt;br /&gt;' leave any other control alone&lt;br /&gt;End If&lt;br /&gt;Next&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;This code in the Listing loops through all the controls on a form and clears each control based on its type. To clear a TextBox control, for example, you would set the Text property to a 0-length string. To clear a CheckBox, you would set the value property to vbUnchecked.&lt;br /&gt;&lt;br /&gt;Notice that the code in the Listing uses an If statement to determine the type of control being cleared. You must make sure you know the type of control you reference to avoid runtime errors. Errors occur if you try to reference a property of a control that is not a valid property. If the first control on a form is a TextBox, you can clear that control by using:&lt;br /&gt;&lt;br /&gt;Me.Controls(0).Text = ""&lt;br /&gt;&lt;br /&gt;If, on the other hand, the first control is a CheckBox that does not have a Text property, with the same code, you will get a runtime error from Visual Basic. The Clear button code example avoids this problem by checking for specific control types within the Controls Collection. The syntax for the If statement is as follows:&lt;br /&gt;&lt;br /&gt;If TypeOf objectname Is objecttype Then&lt;br /&gt;' code&lt;br /&gt;EndIf&lt;br /&gt;&lt;br /&gt;where objectname is the object or control (that is TextBox, ComboBox, and so forth) on which you are working and objecttype is the class of the object. Using this If structure before you reference a control through the Controls Collection will help you avoid runtime errors.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-8688016543710750232?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/8688016543710750232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/05/controls-collection-in-vb6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/8688016543710750232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/8688016543710750232'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/05/controls-collection-in-vb6.html' title='Controls Collection in VB6'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-2317623867044662660</id><published>2011-05-04T19:33:00.002+07:00</published><updated>2011-05-04T19:44:51.875+07:00</updated><title type='text'>Forms Collection pada VB6</title><content type='html'>This section discusses the use of VB's Forms Collection. Topics covered include:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;using methods and properties of the collection, &lt;/li&gt;&lt;li&gt;using specific items within the Forms Collection (referencing individual forms), &lt;/li&gt;&lt;li&gt;looping through the collection, &lt;/li&gt;&lt;li&gt;verifying loaded forms, &lt;/li&gt;&lt;li&gt;unloading forms from the collection.&lt;/li&gt;&lt;/ul&gt;In Visual Basic, a collection is just a group of objects. If you have more than one form in a project, you would have a Forms Collection that you can use to easily manipulate all forms or just one specific form.The Forms Collection is a built-in or intrinsic collection of VB. Another example of a collection built into VB is the Controls Collection that will return all the controls contained on the specified form.&lt;br /&gt;&lt;br /&gt;The Forms Collection contains the loaded forms of all VB form types. MDI Parent forms, MDI Child forms, and non-MDI forms are all included in the collection, along with any forms created at runtime.&lt;br /&gt;&lt;br /&gt;The Forms Collection only contains the forms that are currently loaded in memory. If a project contains multiple forms and only the Startup form has been loaded, the collection will only have one item. To be included in the Forms Collection, all forms must be loaded. They do not have to be shown onscreen, only loaded.&lt;br /&gt;&lt;br /&gt;If a form is the unloaded from memory, that form is no longer part of the Forms Collection. The collection will reduce its count by one, and that form will no longer be available in the collection.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Methods and Properties of the Forms Collection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Most VB collections have various methods or properties that will return information regarding the collection of objects. The Forms Collection has only one property, Count. This property gives the total number of forms currently loaded by the application. To find the total number of forms in the project, just use code such as the following:&lt;br /&gt;&lt;br /&gt;iFormCount = Forms.Count&lt;br /&gt;&lt;br /&gt;To test the Forms.Count property in VB, use a single form and place one command button on the form. Open the code window for the command button and type the code shown in Listing 4.14.&lt;br /&gt;&lt;br /&gt;PROGRAMMING WITH FORMS.COUNT PROPERTY&lt;br /&gt;&lt;br /&gt;Sub Command1_Click()&lt;br /&gt;   Msgbox "The Forms Collection has " &amp;amp; _&lt;br /&gt;   Forms.Count &amp;amp; _&lt;br /&gt;   " forms currently", _&lt;br /&gt;   vbInformation, "Forms Count"&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;This code will show a message box with a string that contains the number of forms in the collection. Remember that only loaded forms are in the collection. Any form that has not been loaded or that has been unloaded will not be part of the collection.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Using specific items within the Forms Collection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Each object in the collection can also be referred to by its specific ordinal number. This is an item number automatically assigned as the new items are added to the collection.&lt;br /&gt;&lt;br /&gt;When referring to the ordinal number of a form, you must always remember that the Forms Collection is 0-based. The first item in the collection will always have the ordinal value of 0. The following lines demonstrate using the item value:&lt;br /&gt;&lt;br /&gt;Forms(0).Caption&lt;br /&gt;Forms(1).Name&lt;br /&gt;Forms(2).Width&lt;br /&gt;&lt;br /&gt;This code assumes that a VB project has three forms and that all forms have been loaded into memory. The first line will return the Caption of the very first item (item 0) in the collection. The second line will return the Name property of Form(1). The third line will return the value of the last form's width.&lt;br /&gt;&lt;br /&gt;These code examples show how easy referencing specific items in the collection can be. This can be an alternative method to using the specific form names in a given project. With the Forms Collection, you also do not have to know the name of a given form to control it. This will assist in manipulating forms generated at runtime.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Looping Through the Forms Collection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another way to use the Forms Collection is with various looping techniques. By using For...Next, For...Each, or Do...While statements, the programmer can loop through the collection to affect all the forms, search for specific forms, and search for specific properties or even values. This will assist in searching for information without having to program every form name individually.&lt;br /&gt;&lt;br /&gt;A simple example would be to retrieve each form's Caption, as shown below.&lt;br /&gt;&lt;br /&gt;LOOPING THROUGH THE FORMS COLLECTION WITH FOR...NEXT&lt;br /&gt;&lt;br /&gt;Dim iLoop as Integer&lt;br /&gt;For iLoop = 0 to Forms.Count - 1&lt;br /&gt;MsgBox Forms(iLoop).Caption&lt;br /&gt;Next iLoop&lt;br /&gt;&lt;br /&gt;This code declares an integer variable for looping and then sets up the For...Next statement. Notice iLoop = 0. You must start at 0 because collections are 0-based. Because you will not always know the amount of forms in the collection, you can take the Forms.Count and subtract 1 from the total. You must remove 1 because the Count starts at 1 and the Collection starts at 0. When this sample code is&lt;br /&gt;run, a message box displays with the Caption property of every form in the collection.&lt;br /&gt;&lt;br /&gt;An alternative to the For... Next loop would be the For...Each loop, which does not depend on an integer counter (see Listing 4.16).&lt;br /&gt;&lt;br /&gt;LOOPING THROUGH THE FORMS COLLECTION WITH FOR...EACH&lt;br /&gt;&lt;br /&gt;Dim frmCurr as Form&lt;br /&gt;For each frmCurr in Forms&lt;br /&gt;MsgBox FrmCurr.Caption&lt;br /&gt;Next frmCurr&lt;br /&gt;&lt;br /&gt;This is probably preferable to the For...Next loop because you don't have to keep track of position in the collection.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Using the Forms Collection to Verify Whether a Form Is Loaded&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When a form is referenced in code, it automatically loads the form into memory. An advantage of the Forms Collection is that it contains only forms that have been loaded into memory. This enables the programmer to test for a specific form by looping through the collection and testing the Name property of every item in the collection.&lt;br /&gt;&lt;br /&gt;An example of this code is found in Listing program below.&lt;br /&gt;&lt;br /&gt;VERIFYING WHETHER A PARTICULAR FORM IS LOADED&lt;br /&gt;&lt;br /&gt;Sub Command1_Click()&lt;br /&gt;   Dim frmCurr as Form&lt;br /&gt;   For each frmCurr in Forms&lt;br /&gt;      If frmCurr.Name = "Form3" Then&lt;br /&gt;         MsgBox "Form3 has been loaded"&lt;br /&gt;      End If&lt;br /&gt;   Next frmCurr&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;This code declares a form variable for looping and then sets up the For...Each statement. Inside the For...Each statement is an If test. With this code you are looking through each item in the collection and testing the property frmCurr.Name. This allows frmCurr to represent every form that is loaded in the collection. If the Name property is equal to Form3, a message box displays informing us that Form3 has been loaded into memory.&lt;br /&gt;&lt;br /&gt;This code sample requires a project with at least three forms. The default form names are expected, and the Form_Load event is responsible for loading all forms into memory. Remember that if the forms are not loaded at the moment the code runs, they will not be included in the collection.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Using the Forms Collection to Unload All Forms&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another common use of the Forms Collection  is to unload all forms. Although the End statement  would provide a faster, simpler way to terminate  the application, it can have unwanted effects  because a call to End will immediately terminate  the application without allowing any further  events (such as Unload events) to run. Looping  through the Forms Collection to unload all members  might seem like a more complicated way to do  the task, but it allows normal processing of  Unload and other events. &lt;p&gt; The code of Listing 4.18 shows one way to  control the loop. First, you must determine  the total number of elements in the collection  then reduce that number by one to accommodate  for that fact that the collection is 0-based.  The loop unloads collection members in reverse  order from the highest-numbered member to the  lowest. This is due to the fact that, after  each unload of a collection member, the number  of members in the collection decreases by one.&lt;/p&gt;&lt;strong&gt;UNLOADING ALL FORMS WITH A DESCENDING FOR...NEXT LOOP&lt;/strong&gt; &lt;p class="text2"&gt; Sub cmdClose_Click()&lt;br /&gt;    Dim iLoop As Integer&lt;br /&gt;    Dim iHighestForm as integer&lt;br /&gt;    iHighestForm = Forms.Count — 1&lt;br /&gt;    For iLoop = iHighestForm To 0 Step — 1&lt;br /&gt;       Unload Forms(iLoop)&lt;br /&gt;    Next iLoop&lt;br /&gt;End Sub&lt;/p&gt; &lt;p&gt; A more elegant way to unload all forms would  be with a For...Each loop, as in the example  of Listing program below.&lt;/p&gt;&lt;strong&gt;UNLOADING ALL FORMS WITH A FOR...EACH LOOP&lt;/strong&gt; &lt;p class="text2"&gt; Sub cmdClose_Click()&lt;br /&gt;    Dim frmCurr as Form&lt;br /&gt;    For each frmCurr in Forms&lt;br /&gt;        Unload frmCurr&lt;br /&gt;    Next frmCurr&lt;br /&gt;End Sub&lt;/p&gt; &lt;p&gt; Both of the above methods assume that at least one form has been loaded in  the collection and that a command button named cmdClose is on one of the loaded  forms. After run, all forms should be unloaded, and the project will terminate  if no other forms are in memory.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-2317623867044662660?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/2317623867044662660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/05/forms-collection-pada-vb6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/2317623867044662660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/2317623867044662660'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/05/forms-collection-pada-vb6.html' title='Forms Collection pada VB6'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-3543508943573208389</id><published>2011-03-18T08:53:00.003+07:00</published><updated>2011-03-18T08:58:16.253+07:00</updated><title type='text'>Understanding Properties, Method, Event in VB</title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Understanding Properties, Methods, and Events&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;All objects in the Visual Basic language, including forms and controls, have their own properties, methods, and events. Properties can be thought of as an object's attributes, methods as its actions, and events as its responses.&lt;br /&gt;An everyday object such as a helium balloon also has properties, methods, and events. A balloon's properties include visible attributes such as its height, diameter, and color. Other properties describe its state (inflated or deflated), or attributes that are not visible, such as its age. All balloons have these properties, although the values of these properties may differ from one balloon to another.&lt;br /&gt;A balloon also has known methods or actions that it can perform. It has an inflate method (filling it with helium), a deflate method (expelling its contents), and a rise method (letting go of it). Again, all balloons are capable of these methods.&lt;br /&gt;Balloons also have responses to certain external events. For example, a balloon responds to the event of being punctured by deflating, or to the event of being released by rising.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/-9KKvG1KhxHI/TYK7ukrGhGI/AAAAAAAAAHs/_4uNptNjXaw/s1600/ObjectBalloon.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 172px;" src="http://1.bp.blogspot.com/-9KKvG1KhxHI/TYK7ukrGhGI/AAAAAAAAAHs/_4uNptNjXaw/s400/ObjectBalloon.JPG" alt="" id="BLOGGER_PHOTO_ID_5585232896685671522" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A balloon has properties (Color, Height, and Diameter), responds to events (Puncture), and can perform methods (Deflate, MakeNoise).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Properties&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you could program a balloon, the Visual Basic code might resemble the following "code," which sets a balloon's properties.&lt;br /&gt;&lt;br /&gt;Balloon.Color = Red&lt;br /&gt;Balloon.Diameter = 10&lt;br /&gt;Balloon.Inflated = True&lt;br /&gt;&lt;br /&gt;Notice the order of the code—the object (Balloon), followed by the property (Color), followed by the assignment of the value (= Red). You could change the balloon's color by substituting a different value.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Methods&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A balloon's methods are called like this.&lt;br /&gt;&lt;br /&gt;Balloon.Inflate&lt;br /&gt;Balloon.Deflate&lt;br /&gt;Balloon.Rise(5)&lt;br /&gt;&lt;br /&gt;The order is similar to that of a property—the object (a noun), followed by the method (a verb). In the third method, there is an additional item, called an argument, which specifies the distance the balloon will rise. Some methods will have one or more arguments to further describe the action to be performed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Events&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The balloon might respond to an event as follows:&lt;br /&gt;&lt;br /&gt;Sub Balloon_Puncture()&lt;br /&gt;    Balloon.MakeNoise("Bang")&lt;br /&gt;    Balloon.Deflate&lt;br /&gt;    Balloon.Inflated = False&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;In this case, the code describes the balloon's behavior when a Puncture event occurs: call the MakeNoise method with an argument of "Bang" (the type of noise to make), then call the Deflate method. Since the balloon is no longer inflated, the Inflated property is set to False.&lt;br /&gt;&lt;br /&gt;While you can't actually program a balloon, you can program a Visual Basic form or control. As the programmer, you are in charge. You decide which properties should be changed, which methods should be invoked, or which events should be responded to in order to achieve the desired appearance and behavior.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-3543508943573208389?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/3543508943573208389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/03/understanding-properties-method-event.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/3543508943573208389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/3543508943573208389'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/03/understanding-properties-method-event.html' title='Understanding Properties, Method, Event in VB'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-9KKvG1KhxHI/TYK7ukrGhGI/AAAAAAAAAHs/_4uNptNjXaw/s72-c/ObjectBalloon.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-8464374065786275129</id><published>2011-03-18T08:39:00.003+07:00</published><updated>2011-03-18T08:52:19.328+07:00</updated><title type='text'>Object Oriented Programming dalam VB</title><content type='html'>&lt;span style="font-weight: bold;"&gt;What is Object Oriented Programming?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Object Oriented Programming allows developers to mimic real world items and concepts. In an OOP world, each object knows what information describes itself and what actions it can perform with that information. OOP allows developers to create reusable objects that interact with each other to form complex entities.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Definition of Classes&lt;/span&gt;&lt;br /&gt;A "Class" is a template which defines the attributes (properties in VB) and the actions or methods which can be performed upon those attributes for a given type of entity. The class definition is used to create "Instances" of the class, which are the actual objects used within your application.&lt;br /&gt;&lt;br /&gt;A Class is generally considered to be a "Black Box". That is, you can use the object created from a Class without knowing how the internal code works. All the developer needs to know is which methods to call to perform certain functions. How those functions perform their tasks is hidden.&lt;br /&gt;&lt;br /&gt;Programmers generally create a Class for each separate entity used within their application. Classes allow developers to write modifiable, readable, reusable code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Objects = Attributes +&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; Actions&lt;/span&gt;&lt;br /&gt;An object is an "Instance" of a Class. In Visual Basic you can create any number of "Object Variables" from a single Class Definition. Each object knows what data describes it and how to manipluate that data.&lt;br /&gt;&lt;br /&gt;Each data item is called an "Attribute" in OOP. Visual Basic implements these attributes as "Properties". Properties are exposed through the Public Interface of an object. Each object can have internal variables, not seen by users, which are used to store information the object requires to perform its task(s).&lt;br /&gt;&lt;br /&gt;Example of An Object Which Exposes Public Properties&lt;br /&gt;&lt;br /&gt;VERSION 1.0 CLASS&lt;br /&gt;BEGIN&lt;br /&gt;MultiUse = -1 'True&lt;br /&gt;END&lt;br /&gt;Attribute VB_Name = "clsPerson"&lt;br /&gt;Attribute VB_Creatable = False&lt;br /&gt;Attribute VB_Exposed = False&lt;br /&gt;&lt;br /&gt;'Internal Member Variables&lt;br /&gt;Private mFirstName as String&lt;br /&gt;&lt;br /&gt;'Public Properties&lt;br /&gt;&lt;br /&gt;Public Property Let FirstName ( Value as String)&lt;br /&gt;'assign Value to internal variable from the outside world&lt;br /&gt;&lt;br /&gt;   mFirstName = Value&lt;br /&gt;&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Public Property Get FirstName ( ) as String&lt;br /&gt;'retreive internal variable and expose to outside world&lt;br /&gt;&lt;br /&gt;   FirstName = mFirstName&lt;br /&gt;&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Objects not only contain their own data but they know how to perform tasks on  that data. Tasks are performed by various functions and procedures defined in  the Class Definition.These functions and procedures are called Methods in OOP.  Once again only those Methods exposed by the Public Interface are available to  outside users.&lt;br /&gt;&lt;p&gt;Example of An Object Which Exposes Public Methods&lt;br /&gt;&lt;br /&gt;VERSION 1.0 CLASS&lt;br /&gt;BEGIN&lt;br /&gt;MultiUse = -1 'True&lt;br /&gt;END&lt;br /&gt;Attribute VB_Name = "clsPerson"&lt;br /&gt;Attribute VB_Creatable = False&lt;br /&gt;Attribute VB_Exposed = False&lt;br /&gt;&lt;br /&gt;'Internal Member Variables&lt;br /&gt;Private mFirstName as String&lt;br /&gt;Private mLastName as String&lt;br /&gt;&lt;br /&gt;'Public Properties&lt;br /&gt;&lt;br /&gt;Public Property Let FirstName ( Value as String)&lt;br /&gt;'assign Value to internal variable from the outside world&lt;br /&gt;&lt;br /&gt;   mFirstName = Value&lt;br /&gt;&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Public Property Get FirstName ( ) as String&lt;br /&gt;'retreive internal variable and expose to outside world&lt;br /&gt;&lt;br /&gt;   FirstName = mFirstName&lt;br /&gt;&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Public Property Let LastName ( Value as String)&lt;br /&gt;'assign Value to internal variable from the outside world&lt;br /&gt;&lt;br /&gt;   mLastName = Value&lt;br /&gt;&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Public Property Get LastName ( ) as String&lt;br /&gt;'retreive internal variable and expose to outside world&lt;br /&gt;&lt;br /&gt;   LastName = mLastName&lt;br /&gt;&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;'Public Methods&lt;br /&gt;&lt;br /&gt;Public Function FullName ( ) as String&lt;br /&gt;'retreives the persons full name&lt;br /&gt;&lt;br /&gt;   FullName = mFirstName &amp;amp; " " &amp;amp; mLastName&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Encapsulation&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;One of the fundamental concepts of OOP is the method with which objects store and manipulate data known as Encapsulation.&lt;br /&gt;&lt;br /&gt;Each object consists of internal variables which, when exposed to outside world, become its' attributes. That is, the data that is input and output from the object. VB defines these exposed attributes as Properties.&lt;br /&gt;&lt;br /&gt;In addition to knowing what data to deal with, each object knows how to manipulate that data. Functions and Procedures that perform tasks are called Methods. A Method can be used internally or exposed to the programmer. If a Method is declared as Private then it can only be used inside the object. The outside world does not see it.&lt;br /&gt;&lt;br /&gt;The developer communicates and controls the object via the Public Interface, a set of Public Properties and Methods which the object exposes to the outside. How an object performs its tasks is of no concern to the developer using the object. It is essentially a "Black Box".&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Inheritance&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;In the pure world of OOP, objects can be created from other objects. Any properties and methods from one class are then automatically available as properties and methods of the new class. This is called Inheritance.&lt;br /&gt;&lt;br /&gt;Visual Basic provides a modified version of Inheritance commonly termed Containment. A class can still expose its childrens' properties and methods but the developer of the class must explicitly reference the child in any calls made to those properties or methods. A comparison is the best way of explaining this concept.&lt;br /&gt;&lt;br /&gt;C++ directly uses Person.Name when Student.Name is called&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/-gkxdEUDbmtU/TYK6FPTGr7I/AAAAAAAAAHc/IofRUF7QUjw/s1600/C%252B%252BCalledObject.bmp"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 339px; height: 104px;" src="http://3.bp.blogspot.com/-gkxdEUDbmtU/TYK6FPTGr7I/AAAAAAAAAHc/IofRUF7QUjw/s400/C%252B%252BCalledObject.bmp" alt="" id="BLOGGER_PHOTO_ID_5585231087061610418" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;VB must explicitly call Person.Name when Student.Name is called&lt;/p&gt;&lt;p&gt;&lt;a href="http://2.bp.blogspot.com/-DB03FdhUug8/TYK6gsGHj7I/AAAAAAAAAHk/2-J864yIBUo/s1600/VBCalledObject.JPG"&gt;&lt;img style="cursor: pointer; width: 363px; height: 111px;" src="http://2.bp.blogspot.com/-DB03FdhUug8/TYK6gsGHj7I/AAAAAAAAAHk/2-J864yIBUo/s400/VBCalledObject.JPG" alt="" id="BLOGGER_PHOTO_ID_5585231558648238002" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Let's look at how you would code this :&lt;br /&gt;&lt;br /&gt; 'Class : clsStudent&lt;br /&gt; ' Contains a reference to a Person Object&lt;br /&gt;&lt;br /&gt; 'private member variables&lt;br /&gt; Private oPerson as clsPerson&lt;br /&gt; Private iGrade as Integer&lt;br /&gt;&lt;br /&gt; Public Sub Create ( )&lt;br /&gt; 'load this object and create the person object&lt;br /&gt;&lt;br /&gt;      Set oPerson = New clsPerson&lt;br /&gt;&lt;br /&gt; End Sub&lt;br /&gt;&lt;br /&gt; Public Property Let Name ( sNewName as String)&lt;br /&gt; 'set the person objects Name Property&lt;br /&gt;&lt;br /&gt;      oPerson.Name = sNewName&lt;br /&gt;&lt;br /&gt; End Property&lt;br /&gt;&lt;br /&gt; Public Property Get Name ( ) as String&lt;br /&gt; 'retreive the person objects Name Property&lt;br /&gt;&lt;br /&gt;      Name = oPerson.Name&lt;br /&gt;&lt;br /&gt; End Property&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Polymorphism&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Objects can be as complex as you desire to make them. Some objects provide the functionality of several different objects with similar behaviours. This is Polymorphism, the ability to change the behaviour of a class based upon certain criteria.&lt;br /&gt;&lt;br /&gt;Lets look at an example :&lt;br /&gt;&lt;br /&gt;Two geographic areas have different methods to calculate Sales Tax.&lt;br /&gt;&lt;br /&gt;Region A calculates Sales Tax at a flat 5% of the Sales Total.&lt;br /&gt;&lt;br /&gt;Region B calculates Sales Tax on a prorated basis - 6% up to $200, 4% for all sales over $200.&lt;br /&gt;&lt;br /&gt;We can create an object class which performs the calculation for Region A, and another class for Region B. Then create a class which references both the previous objects. When you wish to calculate taxes just tell your Wrapper Class which region to use and the proper calculations are performed.&lt;br /&gt;&lt;br /&gt;Here's the code for this example :&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; 'Class : clsTaxRegionA&lt;br /&gt;&lt;br /&gt; Const iTaxRate = .05&lt;br /&gt;&lt;br /&gt; Public function CalcTaxes ( curTaxableValue as Currency) as Currency&lt;br /&gt;&lt;br /&gt;      CalcTaxes = iTaxRate * curTaxableValue&lt;br /&gt;&lt;br /&gt; End Function&lt;br /&gt; 'Class : clsTaxRegionB&lt;br /&gt;&lt;br /&gt; Const iTaxRate1 = .06&lt;br /&gt; Const iTaxRate2 = .04&lt;br /&gt;&lt;br /&gt; Public function CalcTaxes ( curTaxableValue as Currency) as Currency&lt;br /&gt;&lt;br /&gt; If curTaxValue &lt; 200 then&lt;br /&gt;&lt;br /&gt;      CalcTaxes = iTaxRate1 * curTaxableValue&lt;br /&gt;&lt;br /&gt; else&lt;br /&gt;&lt;br /&gt;      CalcTaxes = iTaxRate2 * curTaxableValue&lt;br /&gt;&lt;br /&gt; end if&lt;br /&gt;&lt;br /&gt; End Function&lt;br /&gt; 'Class : clsSalesTax&lt;br /&gt;&lt;br /&gt; 'private member variables&lt;br /&gt; Private sRegion as String&lt;br /&gt; Private oRegionA as clsTaxRegionA&lt;br /&gt; Private oRegionB as clsTaxRegionB&lt;br /&gt;&lt;br /&gt; Public Property Let Region ( sRegionFlag as String )&lt;br /&gt;&lt;br /&gt;      sRegion = sRegionFlag&lt;br /&gt;&lt;br /&gt; End Property&lt;br /&gt;&lt;br /&gt; Public Sub Create ( )&lt;br /&gt;&lt;br /&gt;      Set oRegionA = New clsTaxRegionA&lt;br /&gt;      Set oRegionB = New clsTaxRegionB&lt;br /&gt;&lt;br /&gt; End Sub&lt;br /&gt;&lt;br /&gt; Public function CalcTaxes ( curTaxableValue as Currency) as Currency&lt;br /&gt; 'calculate taxes based on region&lt;br /&gt;&lt;br /&gt; if sRegion = "A" then&lt;br /&gt;&lt;br /&gt;      CalcTaxes = oRegionA.CalcTaxes (curTaxableValue)&lt;br /&gt;&lt;br /&gt; else&lt;br /&gt;&lt;br /&gt;      CalcTaxes = oRegionB.CalcTaxes (curTaxableValue)&lt;br /&gt;&lt;br /&gt; end if&lt;br /&gt;&lt;br /&gt; End Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-8464374065786275129?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/8464374065786275129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/03/object-oriented-programming-dalam-vb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/8464374065786275129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/8464374065786275129'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/03/object-oriented-programming-dalam-vb.html' title='Object Oriented Programming dalam VB'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-gkxdEUDbmtU/TYK6FPTGr7I/AAAAAAAAAHc/IofRUF7QUjw/s72-c/C%252B%252BCalledObject.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-8489955852100071644</id><published>2011-02-24T20:35:00.007+07:00</published><updated>2011-02-25T06:15:53.998+07:00</updated><title type='text'>Getting Started with Visual Basic 6.0</title><content type='html'>Visual Basic 6 Integrated Development Environment&lt;br /&gt;&lt;br /&gt;Visual Basic is initiated by using the Programs option &gt; Microsoft Visual Basic 6.0 &gt; Visual Basic 6.0. Clicking the Visual Basic icon, we can view a copyright screen enlisting the details of the license holder of the copy of Visual Basic 6.0. Then it opens in to a new screen as shown in figure 1 below, with the interface elements Such as MenuBar, ToolBar, The New Project dialog box. These elements permit the user to buid different types of Visual Basic applications&lt;br /&gt;&lt;br /&gt;One of the most significant changes in Visual Basic 6.0 is the Integrated Development Environment (IDE). IDE is a term commonly used in the programming world to describe the interface and environment that we use to create our applications. It is called integrated because we can access virtually all of the development tools that we need from one screen called an interface. The IDE is also commonly referred to as the design environment, or the program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-fMrh6bAXDzk/TWZhThHBwTI/AAAAAAAAAG4/I4GPoM-NHmk/s1600/VB6IDE.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 482px; height: 338px;" src="http://4.bp.blogspot.com/-fMrh6bAXDzk/TWZhThHBwTI/AAAAAAAAAG4/I4GPoM-NHmk/s400/VB6IDE.png" alt="" id="BLOGGER_PHOTO_ID_5577252176478191922" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-CR0C4GkKijE/TWZgeo49vPI/AAAAAAAAAGw/NRwAGqOelb4/s1600/VB6IDE.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Tha Visual Basic IDE is made up of a number of components&lt;br /&gt;&lt;br /&gt;* Menu Bar&lt;br /&gt;* Tool Bar&lt;br /&gt;* Project Explorer&lt;br /&gt;* Properties window&lt;br /&gt;* Form Layout Window&lt;br /&gt;* Toolbox&lt;br /&gt;* Form Designer&lt;br /&gt;* Code Window&lt;br /&gt;* Object Browser, etc.&lt;br /&gt;&lt;br /&gt;In previous versions of Visual Basic, the IDE was designed as a Single Document Interface (SDI). In a Single Document Interface, each window is a free-floating window that is contained within a main window and can move anywhere on the screen as long as Visual Basic is the current application. But, in Visual Basic 6.0, the IDE is in a Multiple Document Interface (MDI) format. In this format, the windows associated with the project will stay within a single container known as the parent. Code and form-based windows will stay within the main container form.&lt;br /&gt;&lt;br /&gt;Visual Basic startup dialog box&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/-REX8Lqx2dsQ/TWZhzY_IvII/AAAAAAAAAHA/U25gB4OfxNA/s1600/VB6Startup.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 382px;" src="http://2.bp.blogspot.com/-REX8Lqx2dsQ/TWZhzY_IvII/AAAAAAAAAHA/U25gB4OfxNA/s400/VB6Startup.png" alt="" id="BLOGGER_PHOTO_ID_5577252724053425282" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Menu Bar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This Menu Bar displays the commands that are required to build an application. The main menu items have sub menu items that can be chosen when needed. The toolbars in the menu bar provide quick access to the commonly used commands and a button in the toolbar is clicked once to carry out the action represented by it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Toolbox&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Toolbox contains a set of controls that are used to place on a Form at design time thereby creating the user interface area. Additional controls can be included in the toolbox by using the Components menu item on the Project menu. A Toolbox is represented in figure 2 shown below.&lt;br /&gt;&lt;br /&gt;Toolbox window with its controls available commonly:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/-GSRvdQccb_o/TWZlhby5Q3I/AAAAAAAAAHI/hKWIO0i0ppw/s1600/VB6ToolBox.png"&gt;&lt;img style="cursor: pointer; width: 226px; height: 400px;" src="http://3.bp.blogspot.com/-GSRvdQccb_o/TWZlhby5Q3I/AAAAAAAAAHI/hKWIO0i0ppw/s400/VB6ToolBox.png" alt="" id="BLOGGER_PHOTO_ID_5577256813616251762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;table class="tabelborder" width="91%" border="1" cellpadding="4" cellspacing="4"&gt;&lt;tbody&gt;&lt;tr class="title"&gt;&lt;td width="21%" height="19"&gt;&lt;div align="left"&gt;&lt;strong&gt;&lt;u&gt;Control&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt; &lt;td width="79%"&gt;&lt;div align="left"&gt;&lt;strong&gt;&lt;u&gt;Description&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="22"&gt;&lt;b&gt;Pointer&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="23"&gt;Provides a way to move and resize the controls form&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="23"&gt;&lt;b&gt;PictureBox&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="23"&gt;Displays icons/bitmaps and metafiles. It displays  text or acts as a visual container for other controls.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="21"&gt;&lt;b&gt;TextBox&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="23"&gt;Used to display message and enter text.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="20"&gt;&lt;b&gt;Frame&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="23"&gt;Serves as a visual and functional container for controls&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="23"&gt;&lt;b&gt;CommandButton&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="23"&gt;Used to carry out the specified action when the user  chooses it.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="21"&gt;&lt;b&gt;CheckBox&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="23"&gt;Displays a True/False or Yes/No option.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="22"&gt;&lt;b&gt;OptionButton&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="23"&gt;OptionButton control which is a part of an option  group allows the user to select only one option even it displays mulitiple choices.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="19"&gt;&lt;b&gt;ListBox&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="23"&gt;Displays a list of items from which a user can select  one. &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="18"&gt;&lt;b&gt;ComboBox&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="23"&gt;Contains a TextBox and a ListBox. This allows the  user to select an ietm from the dropdown ListBox, or to type in a selection in  the TextBox.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="26"&gt;&lt;b&gt;HScrollBar and VScrollBar&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="23"&gt; These controls allow the user to select a value within  the specified range of values&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="23"&gt;&lt;b&gt;Timer&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="23"&gt;Executes the timer events at specified intervals of  time &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="25"&gt;&lt;b&gt;DriveListBox&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="25"&gt;Displays the valid disk drives and allows the user  to select one of them.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="23"&gt;&lt;b&gt;DirListBox&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="23"&gt;Allows the user to select the directories and paths,  which are displayed.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="23"&gt;&lt;b&gt;FileListBox&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="23"&gt;Displays a set of files from which a user can select  the desired one.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="24"&gt;&lt;b&gt;Shape &lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="24"&gt;Used to add shape (rectangle, square or circle) to  a Form&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="24"&gt;&lt;b&gt;Line&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="24"&gt;Used to draw straight line to the Form&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="23"&gt;&lt;b&gt;Image&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="23"&gt;used to display images such as icons, bitmaps and  metafiles. But less capability than the PictureBox&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="24"&gt;&lt;b&gt;Data&lt;/b&gt; &lt;/td&gt; &lt;td width="79%" height="24"&gt;Enables the use to connect to an existing database  and display information from it.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="24"&gt;&lt;b&gt;OLE&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="24"&gt; Used to link or embed an object, display and manipulate  data from other windows based applications.&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width="21%" height="27"&gt;&lt;b&gt;Label&lt;/b&gt;&lt;/td&gt; &lt;td width="79%" height="27"&gt;Displays a text that the user cannot modify or interact  with.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style="font-weight: bold;"&gt;Project  Explorer window&lt;/p&gt;&lt;p&gt;Docked on the right side of the screen, just under the tollbar, is the Project  Explorer window. The Project Explorer as shown in in figure servres as a quick  reference to the various elements of a project namely &lt;em&gt;form&lt;/em&gt;, &lt;em&gt;classes&lt;/em&gt;  and &lt;em&gt;modules&lt;/em&gt;. All of the object that make up the application are packed  in a project. A simple project will typically contain one form, which is a window  that is designed as part of a program's interface. It is possible to develop any  number of forms for use in a program, although a program may consist of a single  form. In addition to forms, the Project Explorer window also lists code modules  and classes.&lt;/p&gt; &lt;p style="font-weight: bold;"&gt;Properties Window&lt;/p&gt;&lt;p&gt;The Properties Window is docked under the Project Explorer window.  The Properties  Window exposes the various characteristics of selected objects. Each and  every  form in an application is considered an object. Now, each object in  Visual Basic has characteristics such as color and size. Other  characteristics affect  not just the appearance of the object but the way it behaves too. All  these characteristics  of an object are called its properties. Thus, a form has properties and  any controls  placed on it will have propeties too. All of these properties are  displayed in  the Properties Window.&lt;/p&gt; &lt;h2&gt;Object Browser&lt;/h2&gt; &lt;p&gt;The Object Browser allows us to browse through the various properties, events  and methods that are made available to us. It is accessed by selecting Object  Browser from the View menu or pressing the key F2. The left column of the Object  Browser lists the objects and classes that are available in the projects that  are opened and the controls that have been referenced in them. It is possible  for us to scroll through the list and select the object or class that we wish  to inspect. After an object is picked up from the Classes list, we can see its  members (properties, methods and events) in the right column.&lt;/p&gt; &lt;p&gt;A property is represented by a small icon that has a hand holding a piece of  paper. Methods are denoted by little green blocks, while events are denoted by  yellow lightning bolt icon.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Object naming conversions of controls (prefix)&lt;/b&gt;&lt;/p&gt; &lt;p class="text2"&gt;Form -frm&lt;br /&gt;Label-lbl&lt;br /&gt;TextBox-txt&lt;br /&gt;CommandButton-cmd&lt;br /&gt;CheckBox -chk&lt;br /&gt;OptionButton -opt&lt;br /&gt;ComboBox -cbo&lt;br /&gt;ListBox-lst&lt;br /&gt;Frame-fme&lt;br /&gt;PictureBox -pic&lt;br /&gt;Image-img&lt;br /&gt;Shape-shp&lt;br /&gt;Line -lin&lt;br /&gt;HScrollBar -hsb&lt;br /&gt;VScrollBar -vsb&lt;/p&gt;&lt;p class="text2"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="text2"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-8489955852100071644?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/8489955852100071644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/02/getting-started-with-visual-basic-60.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/8489955852100071644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/8489955852100071644'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/02/getting-started-with-visual-basic-60.html' title='Getting Started with Visual Basic 6.0'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-fMrh6bAXDzk/TWZhThHBwTI/AAAAAAAAAG4/I4GPoM-NHmk/s72-c/VB6IDE.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-3462294386582179844</id><published>2011-02-21T22:45:00.002+07:00</published><updated>2011-02-21T22:50:08.784+07:00</updated><title type='text'>Characteristics of VB Programming Language</title><content type='html'>Visual Basic (VB) is the third-generation event-driven programming language and integrated development environment (IDE) from Microsoft for its COM programming model. Visual Basic is relatively easy to learn and use.&lt;br /&gt;&lt;br /&gt;Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications, access to databases using Data Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects. Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic, but perform differently.&lt;br /&gt;&lt;br /&gt;A programmer can put together an application using the components provided with Visual Basic itself. Programs written in Visual Basic can also use the Windows API, but doing so requires external function declarations.&lt;br /&gt;&lt;br /&gt;The final release was version 6 in 1998. Microsoft's extended support ended in March 2008 and the designated successor was Visual Basic .NET (now known simply as Visual Basic).&lt;br /&gt;&lt;br /&gt;Like the BASIC programming language, Visual Basic was designed to be easily learned and used by beginner programmers. The language not only allows programmers to create simple GUI applications, but can also develop complex applications. Programming in VB is a combination of visually arranging components or controls on a form, specifying attributes and actions of those components, and writing additional lines of code for more functionality. Since default attributes and actions are defined for the components, a simple program can be created without the programmer having to write many lines of code. Performance problems were experienced by earlier versions, but with faster computers and native code compilation this has become less of an issue.&lt;br /&gt;&lt;br /&gt;Although programs can be compiled into native code executables from version 5 onwards, they still require the presence of runtime libraries of approximately 1 MB in size. This runtime is included by default in Windows 2000 and later, but for earlier versions of Windows like 95/98/NT it must be distributed together with the executable.&lt;br /&gt;&lt;br /&gt;Forms are created using drag-and-drop techniques. A tool is used to place controls (e.g., text boxes, buttons, etc.) on the form (window). Controls have attributes and event handlers associated with them. Default values are provided when the control is created, but may be changed by the programmer. Many attribute values can be modified during run time based on user actions or changes in the environment, providing a dynamic application. For example, code can be inserted into the form resize event handler to reposition a control so that it remains centered on the form, expands to fill up the form, etc. By inserting code into the event handler for a keypress in a text box, the program can automatically translate the case of the text being entered, or even prevent certain characters from being inserted.&lt;br /&gt;&lt;br /&gt;Visual Basic can create executables (EXE files), ActiveX controls, or DLL files, but is primarily used to develop Windows applications and to interface database systems. Dialog boxes with less functionality can be used to provide pop-up capabilities. Controls provide the basic functionality of the application, while programmers can insert additional logic within the appropriate event handlers. For example, a drop-down combination box will automatically display its list and allow the user to select any element. An event handler is called when an item is selected, which can then execute additional code created by the programmer to perform some action based on which element was selected, such as populating a related list.&lt;br /&gt;&lt;br /&gt;Alternatively, a Visual Basic component can have no user interface, and instead provide ActiveX objects to other programs via Component Object Model (COM). This allows for server-side processing or an add-in module.&lt;br /&gt;&lt;br /&gt;The language is garbage collected using reference counting, has a large library of utility objects, and has basic object oriented support. Since the more common components are included in the default project template, the programmer seldom needs to specify additional libraries. Unlike many other programming languages, Visual Basic is generally not case sensitive, although it will transform keywords into a standard case configuration and force the case of variable names to conform to the case of the entry within the symbol table. String comparisons are case sensitive by default, but can be made case insensitive if so desired.&lt;br /&gt;&lt;br /&gt;The Visual Basic compiler is shared with other Visual Studio languages (C, C++), but restrictions in the IDE do not allow the creation of some targets (Windows model DLLs) and threading models.&lt;br /&gt;&lt;br /&gt;Visual Basic has the following traits which differ from C-derived languages:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Multiple assignment available in C language is not possible. A = B = C does not imply that the values of A, B and C are equal. The boolean result of "Is B = C?" is stored in A. The result stored in A would therefore be either false or true.   &lt;br /&gt;&lt;/li&gt;&lt;li&gt;Boolean constant True has numeric value −1. This is because the Boolean data type is stored as a 16-bit signed integer. In this construct −1 evaluates to 16 binary 1s (the Boolean value True), and 0 as 16 0s (the Boolean value False). This is apparent when performing a Not operation on a 16 bit signed integer value 0 which will return the integer value −1, in other words True = Not False. This inherent functionality becomes especially useful when performing logical operations on the individual bits of an integer such as And, Or, Xor and Not.[5] This definition of True is also consistent with BASIC since the early 1970s Microsoft BASIC implementation and is also related to the characteristics of CPU instructions at the time.&lt;/li&gt;&lt;li&gt;Logical and bitwise operators are unified. This is unlike some C-derived languages (such as Perl), which have separate logical and bitwise operators. This again is a traditional feature of BASIC.&lt;/li&gt;&lt;li&gt;Variable array base. Arrays are declared by specifying the upper and lower bounds in a way similar to Pascal and Fortran. It is also possible to use the Option Base statement to set the default lower bound. Use of the Option Base statement can lead to confusion when reading Visual Basic code and is best avoided by always explicitly specifying the lower bound of the array. This lower bound is not limited to 0 or 1, because it can also be set by declaration. In this way, both the lower and upper bounds are programmable. In more subscript-limited languages, the lower bound of the array is not variable. This uncommon trait does exist in Visual Basic .NET but not in VBScript. OPTION BASE was introduced by ANSI, with the standard for ANSI Minimal BASIC in the late 1970s.&lt;/li&gt;&lt;li&gt;Relatively strong integration with the Windows operating system and the Component Object Model. The native types for strings and arrays are the dedicated COM types, BSTR and SAFEARRAY.&lt;/li&gt;&lt;li&gt;Banker's rounding as the default behavior when converting real numbers to integers with the Round function. ? Round(2.5, 0) gives 2, ? Round(3.5, 0) gives 4.&lt;/li&gt;&lt;li&gt;Integers are automatically promoted to reals in expressions involving the normal division operator (/) so that division of one integer by another produces the intuitively correct result. There is a specific integer divide operator (\) which does truncate.&lt;/li&gt;&lt;li&gt;By default, if a variable has not been declared or if no type declaration character is specified, the variable is of type Variant. However this can be changed with Deftype statements such as DefInt, DefBool, DefVar, DefObj, DefStr. There are 12 Deftype statements in total offered by Visual Basic 6.0. The default type may be overridden for a specific declaration by using a special suffix character on the variable name (# for Double, ! for Single, &amp;amp; for Long, % for Integer, $ for String, and @ for Currency) or using the key phrase As (type). VB can also be set in a mode that only explicitly declared variables can be used with the command Option Explicit.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-3462294386582179844?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/3462294386582179844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/02/characteristics-of-vb-programming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/3462294386582179844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/3462294386582179844'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/02/characteristics-of-vb-programming.html' title='Characteristics of VB Programming Language'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-8851069554834931489</id><published>2011-02-21T22:16:00.002+07:00</published><updated>2011-02-21T22:41:50.894+07:00</updated><title type='text'>History of Visual Basic</title><content type='html'>VB 1.0 was introduced in 1991. The drag and drop design for creating the user interface is derived from a prototype form generator developed by Alan Cooper and his company called Tripod. Microsoft contracted with Cooper and his associates to develop Tripod into a programmable form system for Windows 3.0, under the code name Ruby (no relation to the Ruby programming language).&lt;br /&gt;&lt;br /&gt;Tripod did not include a programming language at all. Microsoft decided to combine Ruby with the Basic language to create Visual Basic.&lt;br /&gt;&lt;br /&gt;The Ruby interface generator provided the "visual" part of Visual Basic and this was combined with the "EB" Embedded BASIC engine designed for Microsoft's abandoned "Omega" database system. Ruby also provided the ability to load dynamic link libraries containing additional controls (then called "gizmos"), which later became the VBX interface.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Timeline&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Project 'Thunder' was initiated&lt;/li&gt;&lt;li&gt;Visual Basic 1.0 (May 1991) was released for Windows at the Comdex/Windows World trade show in Atlanta, Georgia.&lt;/li&gt;&lt;li&gt;Visual Basic 1.0 for DOS was released in September 1992. The language itself was not quite compatible with Visual Basic for Windows, as it was actually the next version of Microsoft's DOS-based BASIC compilers, QuickBASIC and BASIC Professional Development System. The interface used a Text user interface, using extended ASCII characters to simulate the appearance of a GUI.&lt;/li&gt;&lt;li&gt;Visual Basic 2.0 was released in November 1992. The programming environment was easier to use, and its speed was improved. Notably, forms became instantiable objects, thus laying the foundational concepts of class modules as were later offered in VB4.&lt;/li&gt;&lt;li&gt;Visual Basic 3.0 was released in the summer of 1993 and came in Standard and Professional versions. VB3 included version 1.1 of the Microsoft Jet Database Engine that could read and write Jet (or Access) 1.x databases.&lt;/li&gt;&lt;li&gt;Visual Basic 4.0 (August 1995) was the first version that could create 32-bit as well as 16-bit Windows programs. It also introduced the ability to write non-GUI classes in Visual Basic. Incompatibilities between different releases of VB4 caused installation and operation problems. While previous versions of Visual Basic had used VBX controls, Visual Basic now used OLE controls (with files names ending in .OCX) instead. These were later to be named ActiveX controls.&lt;/li&gt;&lt;li&gt;With version 5.0 (February 1997), Microsoft released Visual Basic exclusively for 32-bit versions of Windows. Programmers who preferred to write 16-bit programs were able to import programs written in Visual Basic 4.0 to Visual Basic 5.0, and Visual Basic 5.0 programs can easily be converted with Visual Basic 4.0. Visual Basic 5.0 also introduced the ability to create custom user controls, as well as the ability to compile to native Windows executable code, speeding up calculation-intensive code execution. A free, downloadable Control Creation Edition was also released for creation of ActiveX controls. It was also used as an introductory form of Visual Basic: a regular .exe project could be created and run in the IDE, but not compiled.&lt;/li&gt;&lt;li&gt;Visual Basic 6.0 (Mid 1998) improved in a number of areas including the ability to create web-based applications. VB6 has entered Microsoft's "non-supported phase" as of March 2008. Although the Visual Basic 6.0 development environment is no longer supported, the runtime is supported on Windows Vista, Windows Server 2008 and Windows 7. Mainstream Support for Microsoft Visual Basic 6.0 ended on March 31, 2005. Extended support ended in March 2008. In response, the Visual Basic user community expressed its grave concern and lobbied users to sign a petition to keep the product alive. Microsoft has so far refused to change their position on the matter. Ironically, around this time (2005), it was exposed that Microsoft's new anti-spyware offering, Microsoft AntiSpyware (part of the GIANT Company Software purchase), was coded in Visual Basic 6.0. Its replacement, Windows Defender, was rewritten as C++ code.&lt;/li&gt;&lt;li&gt;Visual Basic .NET (VB 7), the original Visual Basic .NET was released alongside Visual C# and ASP.NET in 2002. Significant changes broke backward compatibility with older versions and caused a rift within the developer community.&lt;/li&gt;&lt;li&gt;Visual Basic .NET 2003 (VB 7.1) was released with version 1.1 of the .NET Framework. New features included support for the .NET Compact Framework and a better VB upgrade wizard. Improvements were also made to the performance and reliability of the .NET IDE (particularly the background compiler) and runtime. In addition, Visual Basic .NET 2003 was available in the Visual Studio .NET Academic Edition (VS03AE). VS03AE is distributed to a certain number of scholars from each country without cost.&lt;/li&gt;&lt;li&gt;Visual Basic 2005 (VB 8.0) is the name used to refer to the Visual Basic .NET, Microsoft having decided to drop the .NET portion of the title.&lt;br /&gt;Visual Basic 2005 introduced features meant to fill in the gaps between itself and other "more powerful" .NET languages, adding .NET 2.0 languages features.&lt;/li&gt;&lt;li&gt;Visual Basic 2008 (VB 9.0) was released together with the Microsoft .NET Framework 3.5 on 19 November 2007. &lt;/li&gt;&lt;li&gt;Visual Basic 2010 (VB 10.0) was release in April 2010. Microsoft had planned to use the Dynamic Language Runtime (DLR) for that release but shifted to a co-evolution strategy between Visual Basic and sister language C# to bring both languages into closer parity with one another. Visual Basic's innate ability to interact dynamically with CLR and COM objects has been enhanced to work with dynamic languages built on the DLR such as IronPython and IronRuby. The Visual Basic compiler was improved to infer line continuation in a set of common contexts, in many cases removing the need for the "_" line continuation character. Also, existing support of inline Functions was complemented with support for inline Subs as well as multi-line versions of both Sub and Function lambdas.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-8851069554834931489?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/8851069554834931489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/02/history-of-visual-basic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/8851069554834931489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/8851069554834931489'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/02/history-of-visual-basic.html' title='History of Visual Basic'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-2076852954811779550</id><published>2011-02-21T21:05:00.003+07:00</published><updated>2011-02-21T22:11:44.712+07:00</updated><title type='text'>Visual Programming vs Non Visual Programming</title><content type='html'>a visual programming language (VPL) is any programming language that lets users create programs by manipulating program elements graphically rather than by specifying them textually. A VPL allows programming with visual expressions, spatial arrangements of text and graphic symbols, used either as elements of syntax or secondary notation. Many VPLs (known as dataflow or diagrammatic programming) are based on the idea of "boxes and arrows", where boxes or other screen objects are treated as entities, connected by arrows, lines or arcs which represent relations.&lt;br /&gt;&lt;br /&gt;VPLs may be further classified, according to the type and extent of visual expression used, into icon-based languages, form-based languages, and diagram languages. Visual programming environments provide graphical or iconic elements which can be manipulated by users in an interactive way according to some specific spatial grammar for program construction.&lt;br /&gt;&lt;br /&gt;Current developments try to integrate the visual programming approach with dataflow programming languages to either have immediate access to the program state resulting in online debugging or automatic program generation and documentation (i.e. visual paradigm). Dataflow languages also allow automatic parallelization, which is likely to become one of the greatest programming challenges of the future.&lt;br /&gt;&lt;br /&gt;Note: Microsoft Visual Studio (Visual Basic, Visual C#, Visual J#, etc.) are commonly confused to be but are not visual programming languages. All of these languages are textual and not graphical. MS Visual Studio is a visual programming environment, but not a visual programming language, hence the confusion.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Windows Programming vs DOS Programming&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A Windows program is quite different from its ancient relative, the MS-DOS program. A DOS program follows a relatively strict path from beginning to end. Although this does not necessarily limit the functionality of the program, it does limit the road the user has to take to get to it. A DOS program is like walking down a hallway; to get to the end you have to walk down the hallway, passing any obstacles that you may encounter. A DOS program would only let you open certain doors along your stroll.&lt;br /&gt;&lt;br /&gt;Windows, on the other hand, opened up the world of event-driven programming. Events in this context include, for example, clicking a button, resizing a window, or changing an entry in a text box. The code that you write responds to these events. To go back to the hallway analogy: In a Windows program, to get to the end of the hall, you just click on the end of the hall. The hallway can be ignored. If you get to the end and realize that is not where you wanted to be, you can just set off for the new destination without returning to your starting point. The program reacts to your movements and takes the necessary actions to complete your desired tasks (Visual Basic .NET).&lt;br /&gt;&lt;br /&gt;Another big advantage in a Windows program is the abstraction of the hardware; which means that Windows takes care of communicating with the hardware for you. You do not need to know the inner workings of every laser printer on the market just to create output. You do not need to study the schematics for graphics cards to write your game. Windows wraps up this functionality by providing generic routines that communicate with the drivers written by hardware manufacturers. This is probably the main reason that Windows has been so successful. The generic routines are referred to as the Windows Application Programming Interface (API).&lt;br /&gt;&lt;br /&gt;Another big advantage in a Windows program is the abstraction of the hardware; which means that Windows takes care of communicating with the hardware for you. You do not need to know the inner workings of every laser printer on the market just to create output. You do not need to study the schematics for graphics cards to write your game. Windows wraps up this functionality by providing generic routines that communicate with the drivers written by hardware manufacturers. This is probably the main reason that Windows has been so successful. The generic routines are referred to as the Windows Application Programming Interface (API).&lt;br /&gt;&lt;br /&gt;Visual Basic changed the face of Windows programming by removing the complex burden of writing code for the user interface (UI). By allowing programmers to draw their own UI, it freed them to concentrate on the business problems they were trying to solve. Once the UI is drawn, the programmer can then add the code to react to events.&lt;br /&gt;&lt;br /&gt;Visual Basic has also been extensible from the very beginning. Third-party vendors quickly saw the market for reusable modules to aid developers. These modules, or controls, were originally referred to as VBXs (named after their file extension). Prior to Visual Basic 5.0, if you did not like the way a button behaved, you could either buy or create your own, but those controls had to be written in C or C++. Database access utilities were some of the first controls available. Version 5 of Visual Basic introduced the concept of ActiveX, which allowed developers to create their own ActiveX controls.&lt;br /&gt;&lt;br /&gt;When Microsoft introduced Visual Basic 3.0, the programming world changed again. Now you could build database applications directly accessible to users (so-called front-end applications) completely with Visual Basic. There was no need to rely on third-party controls. Microsoft accomplished this task with the introduction of Data Access Objects (DAO), which allowed programmers to manipulate data with the same ease as manipulating the user interface.&lt;br /&gt;&lt;br /&gt;Versions 4.0 and 5.0 extended the capabilities of Version 3.0 to allow developers to target the new Windows 95 platform. Crucially they also made it easier for developers to write code, which could then be manipulated to make it usable to other language developers. Version 6.0 provided a new way to access databases with the integration of ActiveX Data Objects (ADO). The ADO feature was developed by Microsoft to aid Web developers using Active Server Pages to access databases. All of the improvements to Visual Basic over the years have ensured its dominant place in the programming world. It helps developers write robust and maintainable applications in record time.&lt;br /&gt;&lt;br /&gt;With the release of Visual Basic .NET in February 2002, most of the restrictions that used to exist have been obliterated. In the past, Visual Basic has been criticized and maligned as a “toy” language, as it did not provide all of the features of more sophisticated languages such as C++ and Java. Now, Microsoft has removed these restrictions and made Visual Basic .NET a very powerful development tool. This trend continues with Visual Basic .NET. Although not as drastic a change as from Visual Basic 6 to Visual Basic .NET, there are enough improvements in the language and integrated development environment that Visual Basic .NET is a welcome upgrade and is a great choice for programmers of all levels.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-2076852954811779550?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/2076852954811779550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/02/visual-programming-vs-non-visual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/2076852954811779550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/2076852954811779550'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2011/02/visual-programming-vs-non-visual.html' title='Visual Programming vs Non Visual Programming'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-6942784322626614828</id><published>2008-05-17T13:35:00.001+07:00</published><updated>2011-05-21T10:04:13.852+07:00</updated><title type='text'>Inheritance in Visual Basic</title><content type='html'>&lt;span style="color: rgb(120, 162, 33);font-size:180%;" &gt;&lt;h3&gt;Inheritance&lt;/h3&gt;&lt;/span&gt; &lt;p&gt;In the pure world of OOP, objects can be created from other objects. Any  properties and methods from one class are then automatically available as  properties and methods of the new class. This is called Inheritance.  &lt;/p&gt;&lt;p&gt;Visual Basic provides a modified version of Inheritance commonly termed  Containment. A class can still expose its childrens' properties and methods but  the developer of the class must explicitly reference the child in any calls made  to those properties or methods. A comparison is the best way of explaining this  concept.&lt;/p&gt;Figure 1. C++ directly uses Person.Name when Student.Name is called&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_oX9XsV6agIY/SC59frXAjfI/AAAAAAAAADM/ohKLppG_5Vo/s1600-h/class+diagram+CPP+version.JPG"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_oX9XsV6agIY/SC59frXAjfI/AAAAAAAAADM/ohKLppG_5Vo/s320/class+diagram+CPP+version.JPG" alt="" id="BLOGGER_PHOTO_ID_5201232602828148210" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;Figure 2. VB must explicitly call Person.Name when Student.Name is called&lt;br /&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_oX9XsV6agIY/SC59z7XAjgI/AAAAAAAAADU/pj-4-I0-1tI/s1600-h/class+diagram+VB+version.JPG"&gt;&lt;img style="cursor: pointer;" src="http://4.bp.blogspot.com/_oX9XsV6agIY/SC59z7XAjgI/AAAAAAAAADU/pj-4-I0-1tI/s320/class+diagram+VB+version.JPG" alt="" id="BLOGGER_PHOTO_ID_5201232950720499202" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;Let's look at how you would code this :&lt;br /&gt;&lt;/pre&gt;&lt;table class="MsoTableGrid" style="border: medium none; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 6.15in;" valign="top" width="590"&gt;&lt;pre&gt;&lt;span style="color:green;"&gt;'Class : clsStudent&lt;br /&gt;'Contains a reference to a Person Object&lt;br /&gt;'private member variables&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Private oPerson as clsPerson&lt;br /&gt;Private iGrade as Integer&lt;br /&gt;&lt;br /&gt;&lt;!--[endif]--&gt;Public Sub Create ( )&lt;span style="color:green;"&gt;&lt;br /&gt;'load this object and create the person object&lt;/span&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;Set oPerson = New clsPerson&lt;br /&gt;End Sub  &lt;!--[endif]--&gt;&lt;/pre&gt;&lt;pre&gt;Public Property Let Name ( sNewName as String)&lt;span style="color:green;"&gt;&lt;br /&gt;'set the person objects Name Property&lt;/span&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;oPerson.Name = sNewName&lt;br /&gt;End Property&lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt;&lt;!--[endif]--&gt;&lt;br /&gt;Public Property Get Name ( ) as String&lt;span style="color:green;"&gt;&lt;br /&gt;'retreive the person objects Name Property&lt;/span&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;Name = oPerson.Name&lt;br /&gt;End Property&lt;/pre&gt;&lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p:colorscheme colors="#ffffff,#000000,#808080,#000000,#bbe0e3,#333399,#009999,#99cc00"&gt;&lt;/p:colorscheme&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-6942784322626614828?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/6942784322626614828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2008/05/inheritance-in-visual-basic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/6942784322626614828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/6942784322626614828'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2008/05/inheritance-in-visual-basic.html' title='Inheritance in Visual Basic'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_oX9XsV6agIY/SC59frXAjfI/AAAAAAAAADM/ohKLppG_5Vo/s72-c/class+diagram+CPP+version.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-2231157336421904083</id><published>2008-04-30T13:15:00.000+07:00</published><updated>2008-04-30T13:31:20.523+07:00</updated><title type='text'>Polymorphism in Visual Basic</title><content type='html'>&lt;span style="font-size:85%;"&gt;Ref: &lt;/span&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/z9k8e08x.aspx"&gt;&lt;span style="font-size:85%;"&gt;http://msdn2.microsoft.com/en-us/library/z9k8e08x.aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Polymorphism refers to the ability to define multiple classes with functionally different, yet identically named methods or properties that can be used interchangeably by client code at run time.&lt;br /&gt;&lt;br /&gt;In This Section:&lt;br /&gt;How Visual Basic Provides Polymorphism Illustrates different approaches to polymorphism.&lt;br /&gt;Inheritance-Based Polymorphism Discusses using inheritance to achieve polymorphism.&lt;br /&gt;Interface-Based Polymorphism Discusses using interfaces to achieve polymorphism.&lt;br /&gt;How Visual Basic Provides Polymorphism?&lt;br /&gt;&lt;br /&gt;Traditionally, polymorphism in Visual Basic was done by using interfaces, and interfaces can still be used for this purpose. However, now Visual Basic provides the option of using inheritance to provide polymorphism.&lt;br /&gt;&lt;br /&gt;As with other issues in object-oriented programming, the option to use depends on your specific requirements. In general, use inheritance when you want to create baseline functionality that derived classes can extend; use interfaces when similar functionality has to be provided by multiple implementations that have little in common.&lt;br /&gt;&lt;br /&gt;Most object-oriented programming systems provide polymorphism through inheritance. Inheritance-based polymorphism involves defining methods in a base class and overriding them with new implementations in derived classes.&lt;br /&gt;For example, you could define a class, BaseTax, that provides baseline functionality for computing sales tax in a state. Classes derived from BaseTax, such as CountyTax or CityTax, could implement methods such as CalculateTax as appropriate.&lt;br /&gt;&lt;br /&gt;Polymorphism comes from the fact that you could call the CalculateTax method of an object belonging to any class that derived from BaseTax, without knowing which class the object belonged to.&lt;br /&gt;&lt;br /&gt;The TestPoly procedure in the following Visual Basic Code demonstrates inheritance-based polymorphism:&lt;br /&gt;&lt;br /&gt;' %5.3 State tax&lt;br /&gt;Const StateRate As Double = 0.053&lt;br /&gt;' %2.8 City tax&lt;br /&gt;Const CityRate As Double = 0.028&lt;br /&gt;Public Class BaseTax&lt;br /&gt;    Overridable Function CalculateTax(ByVal Amount As Double) As Double&lt;br /&gt;       ' Calculate state tax.&lt;br /&gt;       Return Amount * StateRate&lt;br /&gt;End FunctionEnd Class&lt;br /&gt;&lt;br /&gt;Public Class CityTax&lt;br /&gt;      ' This method calls a method in the base class&lt;br /&gt;      ' and modifies the returned value.   &lt;br /&gt;      Inherits BaseTax   &lt;br /&gt;     Private BaseAmount As Double&lt;br /&gt;     Overrides Function CalculateTax(ByVal Amount As Double) As Double&lt;br /&gt;      ' Some cities apply a tax to the total cost of purchases,&lt;br /&gt;       ' including other taxes.        &lt;br /&gt;      BaseAmount = MyBase.CalculateTax(Amount)&lt;br /&gt;      Return CityRate * (BaseAmount + Amount) + BaseAmount&lt;br /&gt;End FunctionEnd Class&lt;br /&gt;&lt;br /&gt;Sub TestPoly()&lt;br /&gt;      Dim Item1 As New BaseTax&lt;br /&gt;      Dim Item2 As New CityTax    ' $22.74 normal purchase.&lt;br /&gt;      ShowTax(Item1, 22.74)    ' $22.74 city purchase.&lt;br /&gt;      ShowTax(Item2, 22.74)End Sub&lt;br /&gt;      Sub ShowTax(ByVal Item As BaseTax, ByVal SaleAmount As Double)&lt;br /&gt;     ' Item is declared as BaseTax, but you can&lt;br /&gt;     ' pass an item of type CityTax instead.&lt;br /&gt;     Dim TaxAmount As Double&lt;br /&gt;     TaxAmount = Item.CalculateTax(SaleAmount)&lt;br /&gt;     MsgBox("The tax is: " &amp;amp; Format(TaxAmount, "C"))&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;In this example, the ShowTax procedure accepts a parameter named Item of type BaseTax, but you can also pass any of the classes derived from the BaseTax class, such as CityTax. The advantage of this design is that you can add new classes derived from the BaseTax class without changing the client code in the ShowTax procedure.&lt;br /&gt;&lt;br /&gt;Interface-Based Polymorphism&lt;br /&gt;Interfaces provide another way you can accomplish polymorphism in Visual Basic. Interfaces describe properties and methods like classes, but unlike classes, interfaces cannot provide any implementation. Multiple interfaces have the advantage of allowing systems of software components to evolve without breaking existing code.&lt;br /&gt;&lt;br /&gt;To achieve polymorphism with interfaces, you implement an interface in different ways in several classes. Client applications can use either the old or the new implementations in exactly the same way.&lt;br /&gt;&lt;br /&gt;The advantage to interface-based polymorphism is that you do not need to re-compile existing client applications to get them to work with new interface implementations.&lt;br /&gt;&lt;br /&gt;The following example defines an interface named Shape2 that is implemented in a class named RightTriangleClass2 and RectangleClass2.&lt;br /&gt;A procedure named ProcessShape2 calls the CalculateArea method of instances of RightTriangleClass2 or RectangleClass2:&lt;br /&gt;&lt;br /&gt;Sub TestInterface()&lt;br /&gt;     Dim RectangleObject2 As New RectangleClass2&lt;br /&gt;     Dim RightTriangleObject2 As New RightTriangleClass2&lt;br /&gt;    ProcessShape2(RightTriangleObject2, 3, 14)   &lt;br /&gt;    ProcessShape2(RectangleObject2, 3, 5)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Sub ProcessShape2(ByVal Shape2 As Shape2, ByVal X As Double,  ByVal Y As Double)      &lt;br /&gt;     MsgBox("The area of the object is " &amp;amp; Shape2.CalculateArea(X, Y))End Sub&lt;br /&gt;     Public Interface Shape2&lt;br /&gt;            Function CalculateArea(ByVal X As Double, ByVal Y As Double) As Double&lt;br /&gt;     End Interface&lt;br /&gt;     Public Class RightTriangleClass2&lt;br /&gt;            Implements Shape2&lt;br /&gt;            Function CalculateArea(ByVal X As Double,  ByVal Y As Double) As Double&lt;br /&gt; Implements Shape2.CalculateArea        ' Calculate the area of a right triangle.        &lt;br /&gt;       Return 0.5 * (X * Y) &lt;br /&gt;End Function&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;Public Class RectangleClass2&lt;br /&gt;       Implements Shape2&lt;br /&gt;       Function CalculateArea(ByVal X As Double,  ByVal Y As Double) As Double&lt;br /&gt;       Implements Shape2.CalculateArea        ' Calculate the area of a rectangle.&lt;br /&gt;              Return X * Y&lt;br /&gt;      End Function&lt;br /&gt;End Class&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-2231157336421904083?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/2231157336421904083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2008/04/polymorphism-in-visual-basic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/2231157336421904083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/2231157336421904083'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2008/04/polymorphism-in-visual-basic.html' title='Polymorphism in Visual Basic'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4375924187041747804.post-6066747730776924014</id><published>2008-04-26T14:30:00.000+07:00</published><updated>2011-02-20T22:11:13.741+07:00</updated><title type='text'>VB Object Oriented Programming</title><content type='html'>&lt;p  style="font-family:arial;"&gt;&lt;span style="font-size:78%;"&gt;Reference: http://en.wikibooks.org/wiki/Programming:Visual_Basic_Classic/Object_Oriented_Programming&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:arial;"&gt;We will now move into a more advanced aspect of VB - OOP. But don't worry, Object Oriented Programming is quite simple, in fact it is probably simpler for those who have never programmed before than for those with long experience of traditional Fortran/Basic/Pascal (pick your favourite imperative language).&lt;/span&gt;&lt;br /&gt;&lt;p style="font-family: arial;"&gt;You should be familiar with VB's event-driven programming style by now. However I'll explain it again. When you're doing general VB programming, your thoughts should go in this pattern: "If the user does this, what should happen? How would I make it happen?" Then you would write the program to fit the answers to these questions. That is event-driven programming. You program according to what events the user would trigger. Dragging a picture, clicking a button, and typing a word are all events.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;You, being the brave coder that you are, would ask: "WHY do I HAVE to think like that??"&lt;/p&gt; &lt;p style="font-family: arial;"&gt;Well here's an alternative way for you to think: Object Oriented Programming(OOP). In the world of OOP, you break a problem down into small parts and solve them individually. If you are to program in an object oriented style, you would think of every variable or functions as a property of an object, and everything would seem like an object to you. OOP is hard to explain so you'll have to experience it in the following examples.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;Imagine that you have a bottle of juice. What properties does it have? What events does it have?(What can it do?) Here's a list I could think of:&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; Private Colour As String  'What colour?&lt;br /&gt;Private Fruit As String   'What kind of fruit?&lt;br /&gt;Private Volume As Single  'How much?&lt;br /&gt;Public Sub MakeJuice(c As String, f As String, v As Single)  'Make some&lt;br /&gt;Colour = c&lt;br /&gt;Fruit = f&lt;br /&gt;Volume = v&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Public Sub Evaporate()   'Well, that's the only thing I could think of&lt;br /&gt;Volume = Volume - 10&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Behold. That's our first class. Don't worry about anything right now. I will go over those later. Anyway, let's assume that this class is named, "Juice". Think of it as a general description of a bottle of juice. Now we can create an actual bottle of apple juice:&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; Private AppleJuice As Juice  'Define&lt;br /&gt;Set AppleJuice = New Juice   'Create a new instance of Juice&lt;br /&gt;AppleJuice.MakeJuice "brown", "apple", 30&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Watch:&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; AppleJuice.Evaporate   '20 units left&lt;br /&gt;AppleJuice.Evaporate   '10 left&lt;br /&gt;AppleJuice.Evaporate   'Yes!!&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;"Wait", you interrupted my rant once again, "but why do I have to use OOP? Just because you hate apple juice?"&lt;/p&gt; &lt;p style="font-family: arial;"&gt;OOP is good for large-scale programming - As your code grows large, there are going to be more and more procedures/functions to your program, and your code is going to be so cluttered that one more look at it, you'd scream. That is why I'm teaching you OOP! (So instead of looking at hundreds of scattered procedures/functions, you look at organized Objects.) s&lt;/p&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Types" id="Types"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;User Defined &lt;/span&gt;&lt;span class="mw-headline"&gt;Types&lt;/span&gt;&lt;/h2&gt; &lt;p style="font-family: arial;"&gt;You can think of a type as a simple form of class. Types can only hold variables, not procedures/functions.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;An important distinction between user defined types ('UDT') and and 'classes' in 'VB6' is that 'UDTs' are &lt;i&gt;value types&lt;/i&gt; while 'classes' are &lt;i&gt;reference types&lt;/i&gt;. This means that when you store an object ('instance' of a 'class') in a variable what actually happens is that a pointer to the existing object is stored but when you store a 'UDT' instance in a variable a &lt;i&gt;copy&lt;/i&gt; of the instance is stored. For instance imagine that you have defind a class, 'Class1', and a UDT, 'Type1':&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; Dim ac As Class1&lt;br /&gt;Dim bc As Class1&lt;br /&gt;Dim at As Type1&lt;br /&gt;Dim bt As Type1&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Now assign ac to bc:&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; Set bc = ac&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;and at to bt&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; bt = at&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Now make a change to one of the properties of bc and look at the corresponding property in ac. You should see that when you change bc that ac also changes. This is because ac and bc are really pointers to the same block of memory. If you do the same exercise with bt and at you should see that changing properties of bt does not affect at. This is because at and bt are values not references and occupy distinct locations in memory.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;This is important when storing objects in 'Collections'. If you add an object to a collection you can later change the values of its properties and the object in the collection will also seem to change. in fact it is the same object because what is stored in the collection is the reference ('pointer') to the object. However if you store a 'UDT' in a collection what is stored is a &lt;i&gt;copy&lt;/i&gt; of the &lt;i&gt;values&lt;/i&gt; not a reference so changing the original UDT will not affect the content of the Collection.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Classes" id="Classes"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Classes&lt;/span&gt;&lt;/h2&gt; &lt;p style="font-family: arial;"&gt;Classes are a combination of subroutines and types. By that I mean that when you write a class it looks very much like a &lt;a href="http://en.wikibooks.org/wiki/Programming:Visual_Basic#Types" class="mw-redirect" title="Programming:Visual Basic"&gt;type&lt;/a&gt; but is also contains subroutines and functions.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;Each class in VB6 is a distinct file, there can only be one class in a file and the class cannot be spread out in several files; this is a feature of VB6 not a requirement of object oriented programming.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;A class looks very much like an ordinary module but has the file extension &lt;i&gt;.cls&lt;/i&gt; instead of &lt;i&gt;.bas&lt;/i&gt;&lt;/p&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Inheritance" id="Inheritance"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Inheritance&lt;/span&gt;&lt;/h2&gt; &lt;p style="font-family: arial;"&gt;There are two types of inheritance: implementation and interface. However Visual Basic Classic provides only Interface inheritance. Implementation inheritance can be simulated by a combination of interface inheritance and delegation.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;One of the common ways to introduce inheritance is to show a program that creates dog and cat objects or car and train objects.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;For example in Visual Basic we can declare two classes dog and cat like this:&lt;/p&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Class_cDog" id="Class_cDog"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Class cDog&lt;/span&gt;&lt;/h4&gt; &lt;pre style="font-family: arial;"&gt; Option Explicit&lt;br /&gt;&lt;br /&gt;Public Sub Sound()&lt;br /&gt;Debug.Print "Woof"&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Class_cCat" id="Class_cCat"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Class cCat&lt;/span&gt;&lt;/h4&gt; &lt;pre style="font-family: arial;"&gt; Option Explicit&lt;br /&gt;&lt;br /&gt;Public Sub Sound()&lt;br /&gt;Debug.Print "Meow"&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="module_main" id="module_main"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;module main&lt;/span&gt;&lt;/h4&gt; &lt;pre style="font-family: arial;"&gt; Public Sub main()&lt;br /&gt;Dim oDog as cDog&lt;br /&gt;Dim oCat as cCat&lt;br /&gt;&lt;br /&gt;Set oDog = New cDog&lt;br /&gt;Set oCat = New cCat&lt;br /&gt;&lt;br /&gt;oDog.Sound&lt;br /&gt;oCat.Sound&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;When you run this program it will print:&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; Woof&lt;br /&gt;Meow&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Now this is all very well until you decide that you would like an array of pets:&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; Dim aPets(1 to 10) as ????&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Unless you declare the &lt;i&gt;aPets&lt;/i&gt; array as &lt;i&gt;variant&lt;/i&gt; you have to give it a type. One way is to create a class called &lt;i&gt;cPet&lt;/i&gt; and use it instead of cDog and cCat:&lt;/p&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Class_cPet" id="Class_cPet"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Class cPet&lt;/span&gt;&lt;/h4&gt; &lt;pre style="font-family: arial;"&gt; Option Explicit&lt;br /&gt;&lt;br /&gt;Public IsDog as Boolean&lt;br /&gt;&lt;br /&gt;Public Sub Sound()&lt;br /&gt;If IsDog Then&lt;br /&gt;  Debug.Print "Woof"&lt;br /&gt;Else&lt;br /&gt;  Debug.Print "Meow"&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Now our &lt;i&gt;main&lt;/i&gt; routine might look like this:&lt;/p&gt; &lt;pre style="font-family: arial;"&gt; Option Explicit&lt;br /&gt;&lt;br /&gt;Dim aPet(1 to 10) as cPet&lt;br /&gt;&lt;br /&gt;Public Sub main()&lt;br /&gt;&lt;br /&gt;Dim lPet as Long&lt;br /&gt;&lt;br /&gt;For lPet = 1 to 10&lt;br /&gt;  Set aPet(lPet) = New cPet&lt;br /&gt;  If lPet&lt;=5 then      &lt;br /&gt;      aPet(lPet).IsDog = True    &lt;br /&gt;  Else   &lt;br /&gt;      aPet(lPet).IsDog = False&lt;br /&gt;  End If  &lt;br /&gt;Next lPet     &lt;br /&gt;&lt;br /&gt; 'Now find out what noise they make.  &lt;br /&gt; For lPet = 1 to 10&lt;br /&gt;   aPet(lPet).Sound&lt;br /&gt; Next lPet &lt;br /&gt;&lt;br /&gt;End Sub &lt;/pre&gt; &lt;p style="font-family: arial;"&gt;This should print:&lt;/p&gt; &lt;pre style="font-family: arial;"&gt;Woof&lt;br /&gt;Woof&lt;br /&gt;Woof&lt;br /&gt;Woof&lt;br /&gt;Woof&lt;br /&gt;Meow&lt;br /&gt;Meow&lt;br /&gt;Meow&lt;br /&gt;Meow&lt;br /&gt;Meow&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Look reasonable? For the reqirements so far revealed this works fine. But what happens when you discover that there are things that cats do that have no analogue in dogs? What about other kinds of pet? For example, you want your cat to &lt;i&gt;purr&lt;/i&gt;. You can have a method called &lt;i&gt;purr&lt;/i&gt; but where will you put it? It surely doesn't belong in cPet because dogs can't purr and neither can guinea pigs or fish.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;The thing to do is to separate out those features that are common to all &lt;i&gt;pets&lt;/i&gt; and create a class that deals only with those, we can rewrite &lt;i&gt;cPet&lt;/i&gt; for this purpose. Now we can go back to our original &lt;i&gt;cDog&lt;/i&gt; and &lt;i&gt;cCat&lt;/i&gt; classes and modify them to &lt;i&gt;inherit&lt;/i&gt; the 'interface &lt;i&gt;from&lt;/i&gt; cPet&lt;i&gt;.&lt;/i&gt;&lt;/p&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Class_cPet_rewritten" id="Class_cPet_rewritten"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Class cPet rewritten&lt;/span&gt;&lt;/h4&gt; &lt;pre style="font-family: arial;"&gt; Option Explicit&lt;br /&gt;&lt;br /&gt;Public Sub Sound()&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;Notice that the &lt;i&gt;Sound&lt;/i&gt; method is empty. this is because it exists only to define the interface. The interface is like the layout of the pins on a plug or socket; any plug that has the same layout, size and shape will plug in to a socket implementing the same interface. What goes on inside the thing you plug in is a separate issue; vacuum cleaners and television sets both use the same mains plug.&lt;/p&gt; &lt;p style="font-family: arial;"&gt;To make this work we must now modify cDog and cCat:&lt;/p&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Class_cDog_2" id="Class_cDog_2"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Class cDog&lt;/span&gt;&lt;/h4&gt; &lt;pre style="font-family: arial;"&gt; Option Explicit&lt;br /&gt;Implements cPet&lt;br /&gt;&lt;br /&gt;Private Sub cPet_Sound()&lt;br /&gt;Debug.Print "Woof"&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Class_cCat_2" id="Class_cCat_2"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Class cCat&lt;/span&gt;&lt;/h4&gt; &lt;pre style="font-family: arial;"&gt; Option Explicit&lt;br /&gt;Implements cPet&lt;br /&gt;&lt;br /&gt;Private Sub cPet_Sound()&lt;br /&gt;Debug.Print "Meow"&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Public Sub Purr()&lt;br /&gt;Debug.Print "Purr"&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;p style="font-family: arial;"&gt;&lt;a name="Collections" id="Collections"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h1  style="font-family:arial;"&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Collections&lt;/span&gt;&lt;/h1&gt; &lt;p style="font-family: arial;"&gt;In the pet examples above an array of cPet objects is used to hold the pets. This works well if you know exactly how many pets you have. But what happens if you adopt another stray puppy or your cat has kittens?&lt;/p&gt; &lt;p style="font-family: arial;"&gt;One solution is to use a Collection object instead of an array. A collection object looks a little like an array but lets you add and remove items without worrying about the declared size, it just expands and contracts automatically.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4375924187041747804-6066747730776924014?l=belajarprogramvb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belajarprogramvb.blogspot.com/feeds/6066747730776924014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://belajarprogramvb.blogspot.com/2008/04/vb-object-oriented-programming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/6066747730776924014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4375924187041747804/posts/default/6066747730776924014'/><link rel='alternate' type='text/html' href='http://belajarprogramvb.blogspot.com/2008/04/vb-object-oriented-programming.html' title='VB Object Oriented Programming'/><author><name>Hendra, S.Kom., MT.</name><uri>http://www.blogger.com/profile/10200074729007564731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp0.blogger.com/_oX9XsV6agIY/SCwtZrXAjZI/AAAAAAAAABs/mKKbUKo2dNY/S220/hendra1.JPG'/></author><thr:total>0</thr:total></entry></feed>
