Variable, Constant, Operators   and Control Statement
Variables• Programming element used to store a  value in the program while the program  is running.• It is a name area in ...
• EXPLICIT DECLARATION – declaring variable by  typing DIM (dimension) statement and a  variable name.Syntax: Dim Variable...
Constant• Meaningful Name that takes place of a  number or a string that does not change.• Values that do not change durin...
Operators• Operators are symbols that indicates  operation to be performed on data.There are 3 types of Operators1. Arithm...
Arithmetic Operators- Mathematical Operators that is used to compute inputs from users to generate results.Relational Oper...
Operators           Description                Example       Result   +        Add                                  5+5   ...
Operators Description    Example   Result   >      Greater than    10>8     True   <       Less than      10<8     False  ...
Operators                  Description            Operation will be true if either of the   OR            operands is true...
Condition of AND OperatorCONDITION 1     CONDITION2         RESULT  TRUE             TRUE  TRUE             FALSE  FALSE  ...
Condition of OR OperatorsCONDITION 1     CONDITION2        RESULT  TRUE            TRUE  TRUE            FALSE  FALSE     ...
Condition of XOR OperatorCONDITION 1     CONDITION2         RESULT  TRUE             TRUE  TRUE             FALSE  FALSE  ...
Condition of NOT Operator CONDITION       RESULT  TRUE  FALSE• Negate truth
Get a ¼ sheet of Paper          Find the result1. 9+7+8         6. 10>12. 8^3           7. .05>.53. 65/13         8. 1500>...
Find the result1. 10*10<100 And 12<>122. 500=500.0 Or 95-15<853.True And False4.Not False5.1000/100>77 And 96<>95
ANSWER KEY• 1. 24    •6. TRUE     • 1. FALSE• 2. 512   •7. FALSE    • 2. TRUE• 3. 5     •8. FALSE    • 3. FALSE• 4. 5     ...
CONDITIONAL STATEMENT
Conditional Statement• It is one of the vital components  in programming. It enables a  program to respond in different  m...
Most Commonly Used Conditional Statement.1. If.. Then Statement2. If.. Then.. Else Statement3. If.. Then.. ElseIf Statemen...
If.. Then Statement• The If...Then statement examines the  truthfulness of an expression. It allows  your Program to make ...
If.. Then.. Else Statement• The If...Then statement offers only  one alternative: to act if the  condition is true. Whenev...
If.. Then.. Else StatementSYNTAX:If Condition Then   If Score = 100 Then   Statement1           Label1.caption =“Perfect” ...
If...Then...ElseIf StatementSYNTAX:                          The If...Then...ElseIfIf Condition1 Then                     ...
SELECT CASE STATEMENT• If you have a large number of  conditions to examine,  the If...Then...Else will go through  each o...
SyntaxSelect Case ExpressionCase Expression1     Select Case Subject  Statement1         Case “Mathematics”Case Expression...
LOOP Structure• A loop is an expression used to  repeat an action. Visual Basic  presents many variations of the  loops an...
Do...While Loop• Used to execute a block of statements in  an unspecified number of times while a  condition is false on t...
Do...Loop...While StatementReverse formula ofthe do while         Dim Number As Integerstatement.           Number = 10Syn...
Do...Until...Loop Statement• This loop will first examine the Condition,  instead of examining whether the Condition is  t...
Do...Loop...Until Statement• An alternative to the Do...Until...loop consists  of executing the Statement first.          ...
Get a ¼ Sheet of PaperIdentify the following.1. Name area which holds temporary data.2. Operators that is used to compare ...
6. Declaring a variable without the Dim  Statement.7. A Data type that stores a value of True or  False8. Operators that d...
Identify whether a variable is valid orinvalid1. Name 12. (The_variable)3. My_First_Name4. He&his_Father5.Long_Name_Can_be...
ANSWER KEY1. Variable2. Relational Operator                           1.Invalid3. Loop                    2.Invalid4. Cons...
Upcoming SlideShare
Loading in …5
×

Variable, constant, operators and control statement

408 views
348 views

Published on

Published in: Technology, Spiritual
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
408
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Variable, constant, operators and control statement

  1. 1. Variable, Constant, Operators and Control Statement
  2. 2. Variables• Programming element used to store a value in the program while the program is running.• It is a name area in the memory which holds temporary data. EXAMPLE: Name = “Shaira” Age = text1.text
  3. 3. • EXPLICIT DECLARATION – declaring variable by typing DIM (dimension) statement and a variable name.Syntax: Dim Variable Name As Data type Example: Dim LastName As String• IMPLICIT DECLARATION – declaring a variable without the Dim Statement; simply use the variable on its own. Example: LastName=“Fernandez”
  4. 4. Constant• Meaningful Name that takes place of a number or a string that does not change.• Values that do not change during the execution of the program.Syntax: Const Constant Name As data type = value Example: const Pi As Single = 3.142 Score= 100
  5. 5. Operators• Operators are symbols that indicates operation to be performed on data.There are 3 types of Operators1. Arithmetic Operators2. Relational Operators3. Conditional Operators
  6. 6. Arithmetic Operators- Mathematical Operators that is used to compute inputs from users to generate results.Relational Operators – Operators that is used to compare two values basing on a certain conditions yields a TRUE or FALSE result.Logical Operators – Operators that determine if a particular condition is met. NEXT
  7. 7. Operators Description Example Result + Add 5+5 10 - Substract 10-5 5 / Divide 25/5 5 Integer Division 203 6 (disregards the decimal places) * Multiply 5*4 20 ^ Exponent (power of) 3^3 27 Mod Remainder of division 20 Mod 6 2 "George"&" & String concatenation "George Bush" "&"Bush"
  8. 8. Operators Description Example Result > Greater than 10>8 True < Less than 10<8 False Greater than >= 20>=10 True or equal to Less than or <= 10<=20 True equal to <> Not Equal to 5<>4 True = Equal to 5=7 False
  9. 9. Operators Description Operation will be true if either of the OR operands is true Operation will be true only if both the AND operands are true One sides or other must be true but XOR not both sides NOT Negate truth
  10. 10. Condition of AND OperatorCONDITION 1 CONDITION2 RESULT TRUE TRUE TRUE FALSE FALSE TRUE FALSE FALSE•If there’s a FALSE the result is false.
  11. 11. Condition of OR OperatorsCONDITION 1 CONDITION2 RESULT TRUE TRUE TRUE FALSE FALSE TRUE FALSE FALSE•If there’s a TRUE the result is true.
  12. 12. Condition of XOR OperatorCONDITION 1 CONDITION2 RESULT TRUE TRUE TRUE FALSE FALSE TRUE FALSE FALSE•One sides or other must be true but not bothsides
  13. 13. Condition of NOT Operator CONDITION RESULT TRUE FALSE• Negate truth
  14. 14. Get a ¼ sheet of Paper Find the result1. 9+7+8 6. 10>12. 8^3 7. .05>.53. 65/13 8. 1500>=1501004. 95 mod 955 9.0>=0.005. (-5)+(-4) 10.5<>10
  15. 15. Find the result1. 10*10<100 And 12<>122. 500=500.0 Or 95-15<853.True And False4.Not False5.1000/100>77 And 96<>95
  16. 16. ANSWER KEY• 1. 24 •6. TRUE • 1. FALSE• 2. 512 •7. FALSE • 2. TRUE• 3. 5 •8. FALSE • 3. FALSE• 4. 5 •9. TRUE • 4. TRUE •10. TRUE • 5. FALSE• 5. -9
  17. 17. CONDITIONAL STATEMENT
  18. 18. Conditional Statement• It is one of the vital components in programming. It enables a program to respond in different manner every time a program is executed depending on the data entered.
  19. 19. Most Commonly Used Conditional Statement.1. If.. Then Statement2. If.. Then.. Else Statement3. If.. Then.. ElseIf Statement4. Select Case Statement
  20. 20. If.. Then Statement• The If...Then statement examines the truthfulness of an expression. It allows your Program to make a decision based on the certain condition.• SYNTAX: If condition then Statement/s End If
  21. 21. If.. Then.. Else Statement• The If...Then statement offers only one alternative: to act if the condition is true. Whenever you would like to apply an alternate expression in case the condition is false, you can use the If...Then...Else statement.
  22. 22. If.. Then.. Else StatementSYNTAX:If Condition Then If Score = 100 Then Statement1 Label1.caption =“Perfect” ElseElse Label1.caption =“with Mistakes” Statement2 End IfEnd If
  23. 23. If...Then...ElseIf StatementSYNTAX: The If...Then...ElseIfIf Condition1 Then statement acts like Statement1 the If...Then...ElseElseIf Condition2 Then expression, except Statement2 that it offers asElseIf Condition 3 Then many choices as Statement 3 necessary.End If
  24. 24. SELECT CASE STATEMENT• If you have a large number of conditions to examine, the If...Then...Else will go through each one of them. Visual Basic offers the alternative of jumping to the statement that applies to the state of the condition.
  25. 25. SyntaxSelect Case ExpressionCase Expression1 Select Case Subject Statement1 Case “Mathematics”Case Expression2 lblsubject.caption=“Mathematics” Statement2 Case “Science”Case Expression3 lblsubject.caption=“Science” Statement3 Case “English”End Select lblsubject.caption=“English” End Select
  26. 26. LOOP Structure• A loop is an expression used to repeat an action. Visual Basic presents many variations of the loops and they combine the Do and the Loop keywords.
  27. 27. Do...While Loop• Used to execute a block of statements in an unspecified number of times while a condition is false on the first pass. The statement is not executed.Syntax: Dim Number As Integer Number = 10Do while conditions Do While Number <20 Statement/s Number=Number+2loop Print Number Loop
  28. 28. Do...Loop...While StatementReverse formula ofthe do while Dim Number As Integerstatement. Number = 10Syntax: DoDo Number=Number+2Statement(s) Print NumberLoop While Loop While Number <20Condition
  29. 29. Do...Until...Loop Statement• This loop will first examine the Condition, instead of examining whether the Condition is true, it will test whether the Condition is false.Syntax: Example:Do Until Condition Dim Number As Integer Statement(s) Number=30 Loop Do Until Number <=20 Number= Number-2 Print Number Loop
  30. 30. Do...Loop...Until Statement• An alternative to the Do...Until...loop consists of executing the Statement first. Example: Syntax: Dim Number As Integer Do Number=30 Statement(s) Do Loop Until Number= Number-2 Condition Print Number Loop Until Number <=20
  31. 31. Get a ¼ Sheet of PaperIdentify the following.1. Name area which holds temporary data.2. Operators that is used to compare two values basing on a certain conditions.3. An expression used to repeat an action.4. Values that do not change during the execution of the program.5. symbols that indicates operation to be performed on data.
  32. 32. 6. Declaring a variable without the Dim Statement.7. A Data type that stores a value of True or False8. Operators that determine if a particular condition is met.9. Type of data that consists of numbers which can be manipulated with various standard operators.10. Declaring variable by typing DIM (dimension) statement and a variable name.
  33. 33. Identify whether a variable is valid orinvalid1. Name 12. (The_variable)3. My_First_Name4. He&his_Father5.Long_Name_Can_beuse
  34. 34. ANSWER KEY1. Variable2. Relational Operator 1.Invalid3. Loop 2.Invalid4. Constant5. Operators 3.Valid6. Implicit declaration 4.Invalid7. Boolean8. Conditional operator 5.Valid9. Numerical data type10. Explicit declaration

×