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
departmental store attributes

Databound Controls - A controls use to display the contents of table using Data Control , have to bound each Control to the specific field and the controls are Known as the Data Bo

This is from the book Programming in Visual Basic 2010 by Julia Case Bradley and Anita C. Millspaugh. The assignment is located in Chapter 3 on page 154. Before I type it in, I wou

US WordPress Expert We are functioning on a software application based on WordPress (BuddyPress + Event Manager). Everything as far as functionality is done. Utmost of the styli

The View: The view is used for visualising. For illustration, while performing word processing, the user works on a sequence of words which compose the text. If a user is perf


Coding conventions are recommended that may help you write code via Microsoft Visual Basic Scripting Edition. Coding conventions can include the given: Naming conventions for ob

DOCUMENT VIEW ARCHITECTURE The Document/View architecture is used to build an application based on the Microsoft Foundation Classes library. The Document/View architecture is s

INTRODUCTION TO GUI DESIGN AND FILE HANDLING   The aim of the user interface design is to attain the user's goals. When the user's goals are met, the user is satisfied and the

what are the functions and the importance of hierarchy operators