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
want a visual basic code on Hungarian method

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

What I understand from the assignment is I have to make the VB code in file nu1. xlsm generic, and run several iterations for Kc and Ti to find out the optimal combination which wi

Default Values for GDI Objects: The default color for the brush is white, pen is black, and default bitmap is null and the default font is system.

Part 1: Create an application that allows the user to enter the following employee data: First Name, Middle Name, Last Name, Employee Number, Department, Telephone Number, Telephon

The scope of a variable is finding out by where you declare it. While you declare a variable in a procedure, only code in that procedure can access or alter the value of that varia

MULTIPLE DOCUMENT INTERFACE (MDI) WINDOWS   The SDI (Single document interface) supports one open window or document at a particular time. Microsoft's notepad and paint are il

Illustration of GDI object CPen: 1. Generate a SDI application. And name it as gdipen. 2. Press ctrl (control key) and W altogether to invoke the class wizard. 3. Choose

MODELESS DIALOG The Dialog boxes are either modal or modeless. The modal dialog box should be closed (Unloaded or hidden) before you can continue the working with the rest of t

Let us modify the webTime ASP.NET project that we developed. We will add drop down lists for modifying the different style elements for the label element that displays the time. We