Tuesday 9 September 2014

Class 8

Declaring a variable
The first line in the program would be variable declaration. It includes the Dim statement , name of the variable and the data type.

Dim age as integer
Dim name as String

If you have more than one variable,

Dim a,b,c as Integer (same data type)
Dim x,y as Integer, i,j as Double (different data types)

Now the second step.

We need to give values for those variables.

Dim a as Integer = 100

or

Dim  A as Integer
A=10

Activity

1. Declare the integer variables x,y and z

Dim x,y,z as Integer

2. Assign values 5 to x, 10 to y and 15 to z

x=5
y=10
z=15

3. What are the values of C, N1, N2, N3 :

A=5
B=10
C=A+B
N1=A+10
N2=B
N3=5+N2

C=15( since A is 5 and B is 10)
N1=15 ( A is 5 and add 10 to it)
N2=10(B is 10)
N3=15 (N2 is 10 and add 5 to it)

Sring Functions

1. Print Len("Cotton Boys)

11(including space)

2. Print Left("BCBS", 2)

BC

3. Print Right("Bangalore",4)

lore

4. Print Mid("Sesquicentennial",7,4)

cent

5. Print Ucase("Sony")

SONY

6. Print Lcase("Computer SCIENCE")

computer science

7. Print Instr("Happiness","in")
  
   5 (5 is the place value of i)
   Print Instr("Happiness","at")
   0 (since there is no at in the string Happiness)

8. Print val("40") + val("20")
   
    60
    Print ("40") + ("60")
    4060( since both are NOT numbers but strings, so they are
   joined together not added)

9. Print Replace("World/Wide","/","_")

    World_Wide(/ is replaced with _)
 
 





 

No comments:

Post a Comment