<?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-3879889822910244391</id><updated>2011-04-21T20:30:24.973-07:00</updated><title type='text'>looping vb 2008</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://loopingvb2008.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3879889822910244391/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://loopingvb2008.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-3879889822910244391.post-2242082439930464356</id><published>2009-02-04T02:11:00.000-08:00</published><updated>2009-02-04T02:12:04.729-08:00</updated><title type='text'></title><content type='html'>Visual Basic 2008 Tutorial&lt;br /&gt;Lesson 11: Looping&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Visual Basic 2008 allows a procedure to be repeated as many times as long as the processor could support. This is generally called  looping . Looping is required when we need to process something repetitively until a certain condition is met. For example, we can design a  program that adds a series of numbers until it exceed a certain value, or a program that asks the user to enter data repeatedly until he/she keys in the word 'Finish'. In Visual Basic 2008, we have three types of Loops, they are the For.....Next loop, the Do loop. and the While.....End while loop&lt;br /&gt;&lt;br /&gt;11.1  For....Next Loop&lt;br /&gt;The format is:   &lt;br /&gt;For counter=startNumber to endNumber (Step increment) &lt;br /&gt;&lt;br /&gt;    One or more VB statements &lt;br /&gt;&lt;br /&gt;Next &lt;br /&gt;&lt;br /&gt;Sometimes the user might want to get out from the loop before the whole repetitive process is executed, the command to use is Exit For. To exit a For….Next Loop, you can place the Exit For statement within the loop; and it is normally used together with the If…..Then… statement. For its application, you can refer to example 11.1 d.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example 11.1 a &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;Dim counter as Integer&lt;br /&gt;&lt;br /&gt;For  counter=1 to 10  &lt;br /&gt;&lt;br /&gt;ListBox1.Items.Add (counter)&lt;br /&gt;&lt;br /&gt;  Next &lt;br /&gt;&lt;br /&gt;* The program will enter number 1 to 10 into the list box.&lt;br /&gt; Example 11.1b&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;Dim counter , sum As Integer&lt;br /&gt;&lt;br /&gt;For counter=1  to 100 step 10  &lt;br /&gt;&lt;br /&gt;sum+=counter&lt;br /&gt;&lt;br /&gt;ListBox1.Items.Add (sum)&lt;br /&gt;&lt;br /&gt; Next &lt;br /&gt;&lt;br /&gt;¡¡ &lt;br /&gt;&lt;br /&gt;* The program will calculate the sum of  the numbers as follows: &lt;br /&gt;&lt;br /&gt; sum=0+10+20+30+40+......&lt;br /&gt; &lt;br /&gt;Example 11.1c&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt; Dim counter, sum As Integer&lt;br /&gt;sum = 1000&lt;br /&gt;For counter = 100 To 5 Step -5&lt;br /&gt;sum - = counter&lt;br /&gt;ListBox1.Items.Add(sum)&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;*Notice that increment can be negative. &lt;br /&gt;&lt;br /&gt;The program will compute the subtraction as follow: &lt;br /&gt;&lt;br /&gt;1000-100-95-90-.......... &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt; Example 11.1d&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;Dim n as Integer&lt;br /&gt;&lt;br /&gt;For n=1 to 10&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;If n&gt;6 then&lt;br /&gt;&lt;br /&gt;Exit For&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Else&lt;br /&gt;&lt;br /&gt;ListBox1.Items.Add ( n)&lt;br /&gt;&lt;br /&gt; Next &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;The process will stop when n is greater than 6.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;11.2  Do Loop&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;The formats are &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;a)   Do While condition &lt;br /&gt;&lt;br /&gt;            Block of one or more VB statements &lt;br /&gt;&lt;br /&gt;      Loop &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;b)   Do &lt;br /&gt;            Block of one or more VB statements &lt;br /&gt;      Loop While condition &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;c)    Do Until condition &lt;br /&gt;              Block of one or more VB statements &lt;br /&gt;       Loop &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;d)    Do &lt;br /&gt;             Block of one or more VB statements &lt;br /&gt;&lt;br /&gt;       Loop Until condition &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;* Exiting the Loop&lt;br /&gt;&lt;br /&gt;Sometime we need exit to exit a loop prematurely because of a certain condition is fulfilled. The syntax to use is known as Exit Do. Lets examine the following example&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example 11.2(a)&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;       Do while counter &lt;=1000 &lt;br /&gt;&lt;br /&gt;             TextBox1.Text=counter &lt;br /&gt;&lt;br /&gt;             counter +=1 &lt;br /&gt;&lt;br /&gt;       Loop &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;* The above example will keep on adding until counter &gt;1000. &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;The above example can be rewritten as &lt;br /&gt;&lt;br /&gt;        Do &lt;br /&gt;&lt;br /&gt;               TextBox1.Text=counter &lt;br /&gt;               counter+=1 &lt;br /&gt;&lt;br /&gt;       Loop until counter&gt;1000 &lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;Example 11.2(b)&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;Dim sum, n As Integer&lt;br /&gt;Do&lt;br /&gt;n += 1&lt;br /&gt;sum += n&lt;br /&gt;ListBox1.Items.Add(n &amp; vbTab &amp; sum)&lt;br /&gt;If n = 100 Then&lt;br /&gt;Exit Do&lt;br /&gt;End If&lt;br /&gt;Loop Sub&lt;br /&gt;&lt;br /&gt;¡¡&lt;br /&gt;&lt;br /&gt;In the above  example, we find the summation of 1+2+3+4+……+100.  In the design stage, you need to insert a ListBox into the form for displaying the output, named List1. The program uses the AddItem method to populate the ListBox. The statement ListBox1.Items.Add(n &amp; vbTab &amp; sum) will display the headings in the ListBox, where it uses the vbTab function to create a space between the headings n and sum. &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;a href="http://HowToAddControls.blogspot.com"&gt;How To Add Controls&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://Howtoplayaudio.blogspot.com"&gt;How to play audio vb.net&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://HowtomovetheVisualStudio.NET.blogspot.com"&gt;How to move VisualStudio.NET&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://HowToPrintvb2005.blogspot.com"&gt;How To Print vb2005&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://HowToRemoveItemImportingTextfile.blogspot.com"&gt;Remove Item Importing Textfile&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://koneksialldb.blogspot.com"&gt;koneksialldb&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://Loadingimagefiles.blogspot.com"&gt;Loading image files&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://loadmultiimage.blogspot.com"&gt;load multi image&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://loopingvb2008.blogspot.com"&gt;looping vb2008&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://ManagingSQLServer2005.blogspot.com"&gt;Managing SQLServer2005&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://dokterpc-riaq.blogspot.com"&gt;Dokter PC&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://domaingratis-riaq.blogspot.com"&gt;Trik Domain Gratis&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://dowgamegratis.blogspot.com"&gt;Trik Download game free&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://trikdownloadvideo.blogspot.com"&gt;Trik Download Video&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://broadband-internet-riaq.blogspot.com"&gt;Broadband-internet&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://buatantivirus.blogspot.com"&gt;Trik Buat Antivirus&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://cara-download-dari-google.blogspot.com"&gt;Trik-download-dari-google&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://caramelacakip.blogspot.com"&gt;Trik Cara Melacak IP&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://choosephone.blogspot.com"&gt;Trik Choose Phone&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;a href="http://woodwork-stores.blogspot.com"&gt;Trik woodwork-stores&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=B001F7AHXM&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;iframe src="http://rcm.amazon.com/e/cm?t=woodworkin09c-20&amp;o=1&amp;p=8&amp;l=as1&amp;asins=B000QJPMMQ&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/3879889822910244391-2242082439930464356?l=loopingvb2008.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loopingvb2008.blogspot.com/feeds/2242082439930464356/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://loopingvb2008.blogspot.com/2009/02/visual-basic-2008-tutorial-lesson-11.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3879889822910244391/posts/default/2242082439930464356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3879889822910244391/posts/default/2242082439930464356'/><link rel='alternate' type='text/html' href='http://loopingvb2008.blogspot.com/2009/02/visual-basic-2008-tutorial-lesson-11.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>
