<?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-5943851873527142067</id><updated>2012-02-16T02:05:47.619-08:00</updated><title type='text'>program flow vb2008</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://programflowvb2008.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5943851873527142067/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://programflowvb2008.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>vbnetcode</name><uri>http://www.blogger.com/profile/04926504053784281645</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5943851873527142067.post-5206219865356538341</id><published>2009-02-04T03:07:00.001-08:00</published><updated>2009-02-04T03:07:50.458-08:00</updated><title type='text'></title><content type='html'>Visual Basic 2008 Tutorial&lt;br /&gt;Lesson 9: Controlling Program Flow&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the previous lessons, we have learned how to program code that accept input from the users and display the output without controlling the program flow. In this chapter, you will learn how to program VB2008 code that can make decision when it process input from the users, and control the program flow in the process. Decision making process is an important part of programming because it will help solve practical problems intelligently so that it can provide useful output or feedback to the user. For example, we can write a VB2008 program that can ask the computer to perform certain task until a certain condition is met, or a program that will reject non-numeric data. In order to control the program flow and to make decisions, we need to use the conditional operators and the logical operators together with the If control struture. &lt;br /&gt;9.1  Conditional Operators&lt;br /&gt;&lt;br /&gt; The conditional operators are powerful tool that resemble mathematical  operators that let the VB2008 program compare data values and then decide what actions to take, whether to execute a program or terminate the program and etc. They are also known as numerical comparison operators. Normally they are used to compared two values to see whether they are equal or one value is  greater or less than the other value. The comparison will return true or false result. These operators are shown in Table 9.1. &lt;br /&gt;&lt;br /&gt;Table 9.1: Conditional Operators&lt;br /&gt;&lt;br /&gt;Operator Meaning&lt;br /&gt; &lt;br /&gt;= Equal to&lt;br /&gt; &lt;br /&gt;&gt; More than&lt;br /&gt; &lt;br /&gt;&lt; Less Than&lt;br /&gt; &lt;br /&gt;&gt;= More than and equal&lt;br /&gt; &lt;br /&gt;&lt;= Less than and equal&lt;br /&gt; &lt;br /&gt;&lt;&gt; Not Equal to&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;9.2  Logical Operators&lt;br /&gt;&lt;br /&gt;Sometimes we might need to make more than one comparisons before a decision can be made and an action taken. In this case, using numerical comparison operators alone is not sufficient, we need to use additional operators, and they are the logical operators. These logical operators  are shown in Table 9.2.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;* Normally the above operators are use to compare numerical data. However, you can also compare strings with the above operators. In making strings comparison,  there are certain rules to follows: Upper case letters are less than lowercase letters, "A"&lt;"B"&lt;"C"&lt;"D".......&lt;"Z" and number are less than letters. &lt;br /&gt;&lt;br /&gt;9.3  Using  the If control structure  with the Comparison Operators&lt;br /&gt;To effectively control the VB program flow, we shall use the If control structuret together with the conditional operators and logical operators. There are basically three types of If control structure, namely If....Then statement, If....Then... Else statement and If....Then....ElseIf statement.&lt;br /&gt;&lt;br /&gt;9.3(a) If....Then Statement&lt;br /&gt;This is the simplest control structure which  ask the computer to perform a certain action specified by the VB expression if the condition is true. However, when the condition is false, no action will be performed. The general format for the if...then.. statement is &lt;br /&gt;&lt;br /&gt;If  condition Then &lt;br /&gt;&lt;br /&gt;VB expression&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example 9.1 &lt;br /&gt;Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;Dim myNumber As Integer&lt;br /&gt;myNumber = TextBox1.Text&lt;br /&gt;If myNumber &gt; 100 Then&lt;br /&gt;Label2.Text = " You win a lucky prize"&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;* When you run the program and enter a number that is greater than 100, you will see the "You win a lucky prize" statement. On the other hand, if the number entered is less than or equal to 100, you don't see any display.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;9.3(b) If....Then...Else Statement&lt;br /&gt;Using jus If....Then statement is not very useful in programming and it does not provides choices for the users. In order to provide a choice, we can use the If....Then...Else Statement. This control structure will ask the computer to perform a certain action specified by the VB expression if the condition is true. And when the condition is false ,an alternative action will be executed. The general format for the if...then.. Else statement is &lt;br /&gt;&lt;br /&gt;If  condition Then &lt;br /&gt;&lt;br /&gt;VB expression&lt;br /&gt;&lt;br /&gt;Else&lt;br /&gt;&lt;br /&gt;VB expression&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example 9.2 &lt;br /&gt; Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;Dim myNumber As Integer&lt;br /&gt;myNumber = TextBox1.Text&lt;br /&gt;If myNumber &gt; 100 Then&lt;br /&gt;Label2.Text = " Congratulation! You win a lucky prize"&lt;br /&gt;Else&lt;br /&gt;Label2.Text = " Sorry, You dif not win any prize"&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;* When  you run the program and enter a number that is greater than 100, the statement "Congratulation! You win a lucky prize" will be shown. On the other hand, if the number entered is less than or equal to 100, you will see the "Sorry, You dif not win any prize" statement&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt; &lt;br /&gt; Example 9.3 &lt;br /&gt;Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;Dim myNumber, MyAge As Integer&lt;br /&gt;myNumber = TextBox1.Text&lt;br /&gt;MyAge = TextBox2.Text&lt;br /&gt;&lt;br /&gt;If myNumber &gt; 100 And myAge &gt; 60 Then&lt;br /&gt;Label2.Text = " Congratulation! You win a lucky prize"&lt;br /&gt;Else&lt;br /&gt;Label2.Text = " Sorry, You dif not win any prize"&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;* This program use the logical And operator beside the conditional operators. This means that  both the conditions must be fulfilled in order for the conditions to be true, otherwise the second block of code will be executed. In this example, the number entered must be more than 100 and the age must be more than 60 in order to win a lucky prize, any one of the above conditions not fulfilled will disqualify the user from winning a prize.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;9.3(c) If....Then...ElseIf Statement&lt;br /&gt;If there are more than two alternative choices, using jus If....Then....Else statement will not be enough. In order to provide more choices, we can use the If....Then...ElseIf Statement.  executed. The general format for the if...then.. Else statement is &lt;br /&gt;&lt;br /&gt;If  condition Then &lt;br /&gt;&lt;br /&gt;VB expression&lt;br /&gt;&lt;br /&gt;ElseIf condition Then &lt;br /&gt;&lt;br /&gt;VB expression&lt;br /&gt;&lt;br /&gt;ElseIf condition Then &lt;br /&gt;&lt;br /&gt;VB expression&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;Else&lt;br /&gt;&lt;br /&gt;VB expression&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;Example 9.4 &lt;br /&gt;Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;Dim Mark As Integer&lt;br /&gt;&lt;br /&gt;Dim Grade as String&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Mark = TextBox1.Text&lt;br /&gt;If myNumber &gt;=80 Then&lt;br /&gt;Grade="A"&lt;br /&gt;&lt;br /&gt;ElseIf  Mark&gt;=60 and Mark&lt;80 then&lt;br /&gt;&lt;br /&gt;Grade="B"&lt;br /&gt;&lt;br /&gt;ElseIf  Mark&gt;=40 and Mark&lt;60 then&lt;br /&gt;&lt;br /&gt;Grade="C"&lt;br /&gt;&lt;br /&gt;Else&lt;br /&gt;&lt;br /&gt;Grade="D"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source : http://www.vbtutor.net/vb2008/vb2008tutor.html&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://tampilkan-data.blogspot.com"&gt;Trik Tampilkan-database&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://transfer-login.blogspot.com"&gt;Trik Transfer-login&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://tutorial-mysql.blogspot.com"&gt;Trik Tutorial-MySQL&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://visitor-online.blogspot.com"&gt;Trik visitor-online&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://xampp-security.blogspot.com"&gt;Trik xampp-security&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://member-area-riaq.blogspot.com"&gt;Trik member-area&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://membuat-halmannext.blogspot.com"&gt;Trik Membuat-halman next&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://membuat-security-code.blogspot.com"&gt;Trik membuat-security-code&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://mengecek-karakter.blogspot.com"&gt;Trik mengecek-karakter&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://merubah-pswdroot.blogspot.com"&gt;Trik merubah-pswd root&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://noise-dimouse.blogspot.com"&gt;Trik Noise-dimouse&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://penerapanbug.blogspot.com"&gt;Trik penerapan BUG&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://penggabungan-2web.blogspot.com"&gt;Trik penggabungan-2web&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://perkenalan-dengan-php.blogspot.com"&gt;Trik perkenalan-dengan-php&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://php-login-script.blogspot.com"&gt;Trik PHP-Login-script&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://php-tutorial-riaq.blogspot.com"&gt;Trik PHP-Tutorial&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;iframe src="http://rcm.amazon.com/e/cm?t=woodworkin09c-20&amp;o=1&amp;p=8&amp;l=as1&amp;asins=B000SMVQK8&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5943851873527142067-5206219865356538341?l=programflowvb2008.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programflowvb2008.blogspot.com/feeds/5206219865356538341/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://programflowvb2008.blogspot.com/2009/02/visual-basic-2008-tutorial-lesson-9.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5943851873527142067/posts/default/5206219865356538341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5943851873527142067/posts/default/5206219865356538341'/><link rel='alternate' type='text/html' href='http://programflowvb2008.blogspot.com/2009/02/visual-basic-2008-tutorial-lesson-9.html' title=''/><author><name>vbnetcode</name><uri>http://www.blogger.com/profile/04926504053784281645</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
