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
Question 1 Design a form based applications using labels, text boxes, and buttons to perform basic arithmetic operations on integers Question 2 Describe the concept of Except

In your code A, Function has to always be used on the right side of a variable assignment or in an expression. For illustration: Temp = Celsius(fDegrees) or Msg Box "The C

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

Scenario GetLoan is a new company that will provide a loan of money to individual members of the public.   There are two types of loan to be offered: Secured Loan wher


For reason of readability & consistency, employ the following prefixes along with descriptive names for variables in your VBScript code. S ub type Prefi

Earlier versions of VBScript had no mechanism for making user-defined constants. Constants, if utilized, were implemented as variables & distinguished from other variables by using

Question 1 Write about the Visual Basic Application Development Life cycle with a sample Forms development for performing integer arithmetic operations Question 2 Discuss the

Variant Type: If no data type is related with the VB variables, it takes the default variant type. The variable x will be of the variant type when the two declarations below a

flow chart symbols