Running statements if a condition is true, Visual Basic Programming

Assignment Help:

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


Related Discussions:- Running statements if a condition is true

Program for computing automobile repair bills, A program is needed to assis...

A program is needed to assist computing automobile repair bills. The cost of labor is $35 per hour. The costs for parts are subject to a 5% sales tax, which should be added t

Data control, DATA CONTROL The data control is used to connect to the d...

DATA CONTROL The data control is used to connect to the database. Three properties are very necessary to connect to the database. The primary property is the database name. You

Genetics, GENETICS 1.         The branch genetics started in 1900 after...

GENETICS 1.         The branch genetics started in 1900 after rediscovery of Mendel's work. 2.         Gregor Johann Mendel is called Father of genetics. 3.         The t

Question, #question.algorithemtofindwhetheragivennumberisprime/not.

#question.algorithemtofindwhetheragivennumberisprime/not.

Multiple Forms Issue, i want to use two forms in vb.net. when the progress ...

i want to use two forms in vb.net. when the progress bar in form1 reaches on a specific value then disable form1 and progress bar will stop and the second Form2 will popup which wi

Program to draw a rectangle shape , Create a project that draw a rectangle ...

Create a project that draw a rectangle shape which may be either (*) or (+) according to the selected radio button. The number of rows in the shape will be taken from the 1 st

Error handling in vbscript, While a run-time error takes place, the propert...

While a run-time error takes place, the properties of the Err object are filled with information which uniquely identifies the error & information which can be used to handle it. I

Graphics device interface - windows programming , Graphics Device Interface...

Graphics Device Interface - GDI:   The GDI is a windows API. The GDI uses a set of generic graphics objects to draw to the screen, to the memory and printers. Therefore the p

#tit, anumberisprimeornot

anumberisprimeornot

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd