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

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

Repeating statements while a condition is true, Use the While keyword to ve...

Use the While keyword to verify a condition in a Do...Loop statement. You can verify the condition before you enter the loop (as illustrated in the following ChkFirstWhile instance

Write a program to sort and display an array, Problem 1. Describe the i...

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

Three models for user interface design, THREE MODELS FOR USER INTERFACE DES...

THREE MODELS FOR USER INTERFACE DESIGN   The 3 models for the user interface design are the implementation model, mental model &the manifest model. The Implementation Mod

Use serialize function in document class to implement file, USE OF SERIALIZ...

USE OF SERIALIZE FUNCTION IN DOCUMENT CLASS TO IMPLEMENT FILE void CStoreDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here }

Mr, want a visual basic code on Hungarian method

want a visual basic code on Hungarian method

Features of user interface design, FEATURES OF USER INTERFACE DESIGN Th...

FEATURES OF USER INTERFACE DESIGN The features like how will the software's are used? Who will be the users? What will be the life of the software? During its lifetime how ofte

Appwizard, APPWIZARD   The Appwizard is a tool used for creating a p...

APPWIZARD   The Appwizard is a tool used for creating a project. It follows a series of steps to create a project. Steps Involved in Creating A Project: Step 1: Fr

Introduction to gui design and file handling, INTRODUCTION TO GUI DESIGN AN...

INTRODUCTION TO GUI DESIGN AND FILE HANDLING   The aim of the user interface design is to attain the user's goals. When the user's goals are met, the user is satisfied and the

Hierarchy of operation, what are the functions and the importance of hierar...

what are the functions and the importance of hierarchy operators

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