Running statements if a condition is true, Visual Basic Programming

To run only one statement while a condition is True, employ the single-line syntax for the If...Then...Else statement. The following instance shows the single-line syntax. Notice that this instance omits the Else keyword.

Sub FixDate() Dim myDate

myDate = #2/13/95#

If myDate < Now Then myDate = Now

End Sub

To run more than one line of code, you have to employ the multiple-line (or block) syntax. This syntax comprises the End If statement, as illustrated in the given example:

Sub AlertUser(value)

If value = 0

Then

AlertLabel.ForeColor = vbRed AlertLabel.Font.Bold = True AlertLabel.Font.Italic = True

End If

End Sub

Running particular Statements if a Condition is True & Running Others if a Condition is False

You can employ an If...Then...Else statement to define two blocks of executable statements: one block to run if the condition is True, the other block to run if condition is False.

Sub AlertUser(value) If value = 0 Then

AlertLabel.ForeColor = vbRed

AlertLabel.Font.Bold = True

AlertLabel.Font.Italic = True

Else

AlertLabel.Forecolor = vbBlack AlertLabel.Font.Bold = False AlertLabel.Font.Italic = False

End If

End Sub

 

The following flow chart explained the flow of the above example.

207_Running Statements if a Condition is True.png

Posted Date: 4/18/2013 5:39:50 AM | Location : United States







Related Discussions:- Running statements if a condition is true, Assignment Help, Ask Question on Running statements if a condition is true, Get Answer, Expert's Help, Running statements if a condition is true Discussions

Write discussion on Running statements if a condition is true
Your posts are moderated
Related Questions
Assume you are creating an order entry and editing application for a book store. An order consists of a product, quantity, total price, payment type including Credit/Debit card acc

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

While several operations take place in an expression, each part is evaluated & resolved in a predetermined order called operator precedence. You can employ parentheses to override

Explain difference, Generic Variable: Create Object Ex:-Ole-Automation . No need refer the object library. What is Specific Variable: Binding Procedure Early & Late Binding ( Can

Problem 1. Describe the importance and usage of .net framework in visual Studio 2. Write a program to sort and display an array of integers in ascending order using the conc

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

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

CONTROL ARRAY The control array is a group of similar objects with similar name. Adding controls with control arrays uses less resource than simply adding the multiple controls

MESSAGE LOOP   The message loop is the code in the Win 32 based application. It retrieves messages from the application's message queue and passes these to the related window

I HAVE A C# ASSIGNMENT , WILL I FIND SOMEONE PROFESSIONAL HELP HERE ?