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

ADO.net architecture, write a detailed account on ADO.net architecture.

write a detailed account on ADO.net architecture.

Explain class module and standard module, Difference between Class Module a...

Difference between Class Module and Standard Module? Standard module: -This place for variable declarations,procedures etc.& it can accessed these procedures in whereve

Lotto program, You are asked to create the LOTO game customized according t...

You are asked to create the LOTO game customized according to the following constraints: 1. Create a grid containing 20 numbers (20 buttons: button1, button2, …button20) 2. When t

File system controls, FILE SYSTEM CONTROLS There are 3 file system cont...

FILE SYSTEM CONTROLS There are 3 file system controls as shown in figure. The drive list box, directory list box & the file list box. The drive list box control is used to exhi

Displaying the database - data control, Displaying The Database: The T...

Displaying The Database: The Text box, image box, check box, labels, picture box can be bounded to the data control for exhibiting the data base contents. The two properties a

Do while loop statement, Do While Loop Statement : The statements conta...

Do While Loop Statement : The statements contained by the do...while loop block executes till the condition given in the while is true. The working of do...loop is elaborate

Assigning values to variables, Assigning Values to Variables Values are...

Assigning Values to Variables Values are assigned to variables creating an expression as follows: the variable is on the left side of the expression & the value you desire to a

Create an application, 1. Create a new solution file named Ch03HandsOnProje...

1. Create a new solution file named Ch03HandsOnProject1. 2. Rename the form and set the filename of the form to frmMain and frmMain.vb, respectively. 3. Set the appropriate p

If - else statement, A variation on the If...Then...Else statement lets you...

A variation on the If...Then...Else statement lets you to choose from various alternatives. By adding up Else If clauses expands the functionality of the If...Then...Else statement

Cdatabase class - database application, Cdatabase Class: The CDataBase...

Cdatabase Class: The CDataBase class helps to connect to the data source. The Open member function opens a connection to the data source. CRecordset class is used for performi

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