0% found this document useful (0 votes)
2 views8 pages

Lesson Six

Uploaded by

sandrarashid77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

Lesson Six

Uploaded by

sandrarashid77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Language constructs : Variables

◎ Two category of Variable declaration.


1. Explicit: An explicit declaration is the appearance of an
identifier (a name) in a DECLARE statement, as a label prefix, or
in a parameter list. A name is explicitly declared if it appears as
follows: In a DECLARE statement. Example: Dim x As Integer;
2. Implicit: If a name appears in a program and is not explicitly
declared, it is implicitly declared. Example X= 10

Atupele Cairo 1
Language constructs : Data Types
◎ Data types specify the kind of data a variable can store, such as
numbers, text, or Boolean values.
◎ Dim myInteger As Integer
Dim myString As String
Dim myBoolean As Boolean

myInteger = 10
myString = "Hello, DIT!"
myBoolean = True

Atupele Cairo 2
Language constructs : Data Types
◎ Range variable: To use a range or a single cell as a variable,
first, you need to declare that variable with the range data type
(object variable).
◎ Dim r As Range
◎ Set r = Range("b16")
◎ r = 60

Atupele Cairo 3
Language constructs :Operators
◎ Operators perform operations on data (e.g., addition,
subtraction, comparison).
Dim num1 As Integer
Dim num2 As Integer
Dim result As Integer
num1 = 10
num2 = 5
result = num1 + num2 ' Addition
result = num1 - num2 ' Subtraction
result = num1 * num2 ' Multiplication
result = num1 / num2 ' Division
result = num1 Mod num2 ' Modulo
Atupele Cairo 4
Language constructs : Control
Statements
◎ Control Statements control the flow of program execution
(e.g., if statements, loops).
Dim num As Integer
num = 10
If num > 0 Then
MsgBox("Number is positive.")
Else
MsgBox("Number is non-positive.")
End If
Atupele Cairo 5
Language constructs : Comments
◎ Step 1: Click on the line where you want to insert a comment.
◎ Step 2: Type an Apostrophe( ' ) at the start of a line.
◎ Step 3: Write the comment you want. Step
◎ 4: Press Enter and you fill find the comment written to be
green.

Atupele Cairo 6
Thanks!

Atupele Cairo 7
Question
Write a program that add three
numbers
Write a program that identify
positive numbers
Add a comment in your
program
Atupele Cairo 8

You might also like