Programming Lesson 2 (22/09/14)

In today's lesson, we looked into some of the basic functions available in Visual Studio.

First of all, we discussed the components of various lines of code, identifying Data Types, Variable Declarations, Expressions, Arithmetical Operators and Selection Statements.

We then studies the two main selection statements in detail; If Statements and Case Statements. An IF statement looks like this;

If Age >= 18 Then
  MsgBox("You are an adult.")
Else
  MsgBox("You are a child.")
End If

While a Case Statement goes like this;

Select Case Age
Case 0 to 17
    MsgBox("You are a child.")
Case Else
  MsgBox("You are an adult.")
End Select

If statements are more generally used, but Case statements are useful if many possibilities are to be considered, to avoid lengthy If statements.

Towards the end of the lesson, we moved on to trying out our own VB programs, performing calculations, such as subtracting the inside area of a circle from the outside area, to find the overall area of a washer.

Comments

Popular posts from this blog

Sorting (17/3/15)

Networks and the Internet (16/3/15)