about-knowledge.com

rss

Selection Programming and Sub Procedure Programming Using VB 6.0

without comments

Selection Programming Using VB 6.0

Selection is a method of writing programs to choose between two or among different things, such as to select a job opportunity offer from two different organizations. If-then-else structure is used for selection programming. Relational operators are used for comparison among different things, such as greater than and less than.

Expression Symbols In VB
Equal To =
Not Equal To <>
Greater Than >
Less Than <
Greater Than and Equal To >=
Less Than and Equal To <=

Selection structure is of three types:

  1. Single Selection structure.
  2. Double Selection structure.
  3. Multiple Selection structure.

Single selection structure is used to choose one thing only. Syntax of single selection structure is shown below:

If username = "Burhan" Then
Print "Accept"
End If

Double selection structure is used to choose between two things. Syntax of double selection structure is show below:

If username = "Burhan" Then
Print "Accept"
Else
Print "Reject"
End If

Multiple selection structure is used to choose among different things. Syntax of multiple selection structure is show below:

If username = "Burhan" Then
Print "Accept"
ElseIf username = "Yahya"
Print "Accept"
Else
Print "Reject"
End If

Sub Procedure Programming Using VB 6.0

Sub procedure is declared to divide the main problem of the program into smaller problems. Programmers used sub procedures to get benefits of modular approach. Sub procedure does not return value. Standard module window is normally used to declare procedures. These are the steps to add a sub procedure:

  • Click on the code window after opening a standard exe form.
  • Select Add procedure from the tools menu.
  • Enter a name in the Add procedure dialog box.
  • Select private for scope. Choosing a public means that procedure will be available for other project modules.
  • Leave the Type set to develop a sub procedure.
  • Click OK.

Syntax of a sub procedure is shown below:

[Private] [Public] Sub Procedure_Name (arguments)
End Sub

A procedure can be declared with or without arguments. The statements between Sub and End sub are executed every time when a procedure is called. A function name ‘Call’ is used to call a procedure.

Bookmark and Share

Related posts:

  1. Repetition Programming and Function Procedure Programming Using VB 6.0 Repetition Programming Using VB 6.0 Repetition programming structure is used...
  2. Software Coding-Approaches of High Level Programming Languages (Part One)-Structured Programming There are four main approaches followed to code a software...
  3. Fundamentals of VB 6.0 Programming and Programming to Display a String Fundamentals of VB 6.0 Programming VB 6.0 helps a programmer...
  4. Menu Programming and Multiple Form Programming Using VB 6.0 Menu Programming Using VB 6.0 A menu is a collection...
  5. Programming of Arithmetic Operators and Predicates and Programming to use Append Using Structures Programming of Arithmetic Operators and Predicates Prolog is used to...

Written on

May 8th, 2009 at 4:59 pm