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
Software That Is Obscure: The Software hides the intensions, meaning and actions from the user. For illustration, if a user is asked whether a full installation, the custom in

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.

departmental store attributes

Case: Design a web page that contains the VBScript utilized for calculating subtotals, taxes, discounts & totals as well as code utilized to validate use

what are the functions and the importance of hierarchy operators

want a visual basic code on Hungarian method

Shopping Cart Purpose – Allows user to browse while keeping track of the items in which they will purchase at the end on the order page link and this will give a final price for al

DIALOG BOXES IN VB The two dialog boxes, namely, the message box and the input box are usually used in the Visual Basic. The message box is used for displaying the messages to

Depreciation to a Salvage Value of 0.   For tax purposes an item may be depreciated over a period of several years, n. With the straight-line method of depreciation, each year th

steps of connecting database from vb6.0