Translate

Monday, 3 June 2013

Decision Making using VB.NET


Control Structure
Let us SEE control structure in VB.NET

Consider you go to fruit shop and ask for whether the shop sell apple or not just by asking the you get the answer similarly you are going to this in VB.NET.  First let us see an example .

Module Example5
    Sub main()
        Dim Asked As String = "apple"
        If Asked = "apple" Then
            Console.WriteLine("Apple Avalable!")
        Else
           Console.WriteLine("Not Avalable!")
        End If
        Console.ReadKey()
    End Sub
End Module

 
In the above example a string variable Asked is assigned with “apple” . One important thing I forgot to mention in the previous blog that string values are assigned with double quotes “ ” all other variables like Integer , Single (we have not seen yet ) are simple assign without quotes.

The statement
        If Asked = "apple" Then

Checks if  Asked variable value is “apple”  if it is statement in the if block is executed otherwise statement in the  Else block is executed.

Syntax of If Else Control  Structure
If condition then
Statements
Else
Statements
End If

We will see Examples in  If Else  Control Structure in the upcoming blogs.

No comments:

Post a Comment