For next repetition - control statement, Visual Basic Programming

Assignment Help:

For ..... Next Repetition Statement:

To demonstrate the working of for .. next control statement, put a command button and a label control on the form. The Handle clicks the event for the command button. Now type the coding shown below as the event handler.

Private Sub Command1_Click()

Label1.Caption = "for loop illustration"

For i = 1 To 10

Form1.Print " the value of i is"; i

Next

End Sub

The Label control cannot be navigated. Whenever you press the tab key during the execution, the order in which the controls will be visited will be highlighted for every tab press. This is termed as the tab order. The Label control will not have a tab order. Primarily the Label control is used for displaying the heading. You set the caption property of the label control. During execution the caption will be exhibited on the form where the label control is placed. The common syntax of for loop is as shown below:

For index = initial value to end value (Step value)

One or more VB statements

Next

The for loop uses an index, namely "i", in this demonstration. The index is assigned the starting value, namely 1 as given. The keyword "To" tell the collection of values the index can take. The integer following "to" is the final value that is 10 in this illustration. Therefore, i, will start with 1 and raise by 1 till it reaches to 10. For each and every value of i, the statements between for and the next would be executed.

When the button is clicked "for loop illustration" will be displayed in the position where label control was placed. The following output would also be displayed on the screen as shown in figure.

the value of i is 1

the value of i is 2

the value of i is 3

....

the value of i is 10

2320_next control statement.png

Figure: Illustration of for next control statement

Specifying the Step Value:

For i = 10 To 1 Step -1

In the former for statement Step was not explicitly stated. Whenever it is not explicitly stated it is taken as 1 by default. In the above statement, the Step is specified as -1. Therefore the value will be decremented by 1 for each iteration. The index starts with 10 and is decremented by 1 for each iteration until it reaches to 1. 


Related Discussions:- For next repetition - control statement

Explain class module and standard module, Difference between Class Module a...

Difference between Class Module and Standard Module? Standard module: -This place for variable declarations,procedures etc.& it can accessed these procedures in whereve

File system controls, FILE SYSTEM CONTROLS There are 3 file system cont...

FILE SYSTEM CONTROLS There are 3 file system controls as shown in figure. The drive list box, directory list box & the file list box. The drive list box control is used to exhi

Ddx - dialog data exchange, DDX - Dialog Data Exchange: The Data membe...

DDX - Dialog Data Exchange: The Data members can be related with specific controls in the dialog box. When the dialog box is displayed, the DDX will transfer the values into t

Cdatabase class - database application, Cdatabase Class: The CDataBase...

Cdatabase Class: The CDataBase class helps to connect to the data source. The Open member function opens a connection to the data source. CRecordset class is used for performi

Check whether a number is palindrome or not, Function IsPalindrome(str) ...

Function IsPalindrome(str) Dim iStart,iEnd,ctr,blnPalin str=trim(str) blnPalin=true iEnd=len(str) iCnt=round(iEnd / 2) iStart=1 for ctr=1 to cint(iCnt) if(mid(str,iEnd,

Create a vb application to make the text bold, Question 1 Create a VB appl...

Question 1 Create a VB application to make the text bold, italic, underlined and also color the text (using checkbox, option button, textbox controls) Question 2 Create a

Recurson, types and concept of recurson

types and concept of recurson

Project, I have a project due tomorrow that I am really struggling in. Plea...

I have a project due tomorrow that I am really struggling in. Please help.

How to replace the text from textbox to another., I''m doing a project on v...

I''m doing a project on vb.NET. I''m stuck with this place where I should replace the text to different characters from textbox1 to textbox2 without changing text in textbox1. For

For each next loop - vbscript, A For Each...Next loop is similar to a For.....

A For Each...Next loop is similar to a For...Next loop. Rather than repeating the statements a particular number of times, For Each...Next loop repeats group of statements for each

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd