Programming Language Fundamentals (Visual Basic) : Cyrenz D. Tan Ana Joy Portolito Bscpe-5
Programming Language Fundamentals (Visual Basic) : Cyrenz D. Tan Ana Joy Portolito Bscpe-5
Language
Fundamentals
(Visual Basic)
Cyrenz D. Tan
Ana Joy Portolito
BSCpE-5
Application Programs
History of Programming
Languages
Machine
language
Procedure-oriented
languages
Object-oriented
Event-driven
Natural
languages
languages
languages
Common Programming
Languages
Basic Controls
Others
Properties Window
Event
Event
Form
Button
Textbox
Dim
Assignment
<variable> = <expression>
flag = false
Constructors
Characteristics of a
Constructor:
Constructor Example:
Public Class Student
' Member variables
Private strLastName As String
Private strFirstName As String
Private strId As String
Private sngTestAvg As Single 'Holds
' Constructor
Public Sub New()
strFirstName = "(unknown)"
strLastName = "(unknown)"
strId = "(unknown)"
sngTestAvg = 0.0
End Sub
(The rest of this class is omitted.)
End Class
Control Statements
if... Then
if...Then ...Else
Nested If...Then...Else
Select...Case
Do While...Loop
While...Wend
For...Next
Control Statement
The If...Then selection structure performs an indicated action only when the
condition is True; otherwise the action is skipped.
Syntax of theIf...Thenselection
If <condition> Then
statement
End If
e.g.: If average>75 Then
txtGrade.Text = "A"
End If
Continuation
Continuation..
Continuation.
Syntax of the NestedIf...Then...Elseselection
structure
Method 2
Method 1
If < condition 1 > Then
If < condition 1 > Then
statements
statements
Else
ElseIf < condition 2 > Then
If < condition 2 > Then
statements
statements
ElseIf < condition 3 > Then
Else
If < condition 3 > Then
statements
statements
Else
Else
Statements
Statements
End If
End If
End If
EndIf
Continuation.
Continuation.
Continuation.
Case 64 To 55
txtGrade.Text =2.5"
Case 54 To 45
txtGrade.Text =3.0"
Case 44 To 0
txtGrade.Text =5.0"
Case Else
MsgBox "Invalid average marks"
End Select
Continuation.
Loop
Structures
Continuation.
Do While
Do Until
For...Next
Continuation.
Do
Syntax:
Do While [Condition]
[Statements]
Loop
Continuation.
Example:
Private Sub Command1_Click()
Dim a As Integer
a=1
Do While a < 100
a=a*2
MsgBox ("Product is::" & a)
Loop
End Sub
Do Until loop
Syntax:
Do Until Condition
statement(s)
Loop expression
Continuation.
Syntax:
For Counter = StartValue To EndValue[Step Value]
statement[s]
Next [Counter]
Continuation.
Syntax:
While condition
[statements]
Wend
Continuation.
In general, there are two categories of
loops:
Pretest Loops
Posttest Loop
the loop condition gets evaluated at the end of the loop cycle