Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

Make money selling software. Check this out here

Hosted clickbank mall. Check this out here




   Misc

   Amazon

   Links

Conditional Statements in Visual Basic.NET


 

 

The Conditional Statements Explained

If...Else...ElseIf Statement

If/Else Statments are used to conditionally execute code based on condition provided. If the condition provided in the If statement evaluates to true, the code in the block is executed. Otherwise, execution would proceed to the optional ElseIf statements, or the Else statement. ElseIf and Else are not required parts of an If statement.

An example of the If/Else/ElseIf branch statement is:

'The following variable declarations are for the following example only. They are not needed in real life.
Dim x As Integer
Dim
y As Integer
If
x = y Then
'Whatever will happen if x = y
ElseIf
x < y Then
'Whatever will happen if x < y

Else

'Whatever will happen if x isn't = to y and x isn't < to y

End If

Select Case Statement

Either strings or numbers can be used for a Select Case statement.

Select Case statements are usually used to avoid long chains of If/ElseIf/.../ElseIf/Else statements.

An example of a Select Case branch statement using an integer is:

Dim nCPU as Integer
Select Case nCPU
    Case 0
        'No CPU!
    Case 1
        'Single CPU
    Case 2
        'Dual CPU machine
    Case 4
        'Quad CPU machine
    Case 3, 5 To 8
        '3, 5, 6, 7, 8 CPU's
    Case Else
        'Something more than 8
End Select
                                          

 

 

All text is available under the terms of the GNU Free Documentation License
Source : Wikibooks


 

 



 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
Shutdown Windows(VB)
basic web control example(VB)
copy a file(VB)
shockwave text(Javascript)
random circles(Darkbasic)
basic web control example(VB)
Ping with VB(VB)
The Register news(PHP)




Copyright © 2004 by programmershelp.co.uk