If then else - control statement, Visual Basic Programming

If Then Else:

The control statement If Then Else is used for computing a condition and taking the action based on the condition. If the condition is true then the section will execute or else block will execute.

If .. Then...Else:

If condition Then

Block of VB Statements

Else

Block of VB Statements

End If

To use If then Else construct you can place a button and the text box on the form as given in the figure. Now Run the project and enter the value in the text box and then click the button. The event handler given below executes and if the value entered surpasses 50 it displays passes, or else it displays fail.

Private Sub Command1_Click()

If Val(Text1.Text) > 50 Then

Form1.Print "pass"

Else

Form1.Print "fail"

End If

End Sub

2370_if then else.png

Figure: Illustration of If then Else

Posted Date: 10/9/2012 8:28:27 AM | Location : United States







Related Discussions:- If then else - control statement, Assignment Help, Ask Question on If then else - control statement, Get Answer, Expert's Help, If then else - control statement Discussions

Write discussion on If then else - control statement
Your posts are moderated
Related Questions
The Frame: As the name suggests, the frame is a combination of the building blocks, structure and the borders of an item. The frame gives the "physical" presence to a window.

how to make logic of o program and how to use loop

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,

VBScript Operators VBScript contain a full range of operators, including comparison operators, arithmetic operators, concatenation operators, and logical operators.

ToolTip: The ToolTip property is used to flash a message regarding a control object when the mouse pointer moves over that object for a couple of seconds. Pick a control and c

WINDOWS 32 BIT (WIN 32) APPLICATIONS   The Win 32 based applications are the applications developed for the windows family of the operating systems. The Win 32 applications ac

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

PROJECT TO CREATE SPLITTER WINDOW   1. Generate the SDI application. 2. Enlarge the class tab page. 3. Select the view class. 4. On right clicking the menu pops up.

For naming anything variable names follow the standard rules in VBScript. A variable name: Should begin with an alphabetic character. Cannot have an embedded period. Sh

GENETICS 1.         The branch genetics started in 1900 after rediscovery of Mendel's work. 2.         Gregor Johann Mendel is called Father of genetics. 3.         The t