computer (sec .1) mr.khaled anwar (01003340348) · 2018-02-01 · 1 mr.khaled anwar (01003340348)...

44
1 Mr.Khaled Anwar (01003340348) Computer (Sec.1) Second Term The Rnd() function generates random numbers. Every time Rnd() is executed, it returns a different random fraction (greater than or equal to 0 and less than 1). If you end execution and run the program again, you will notice that it produces the same sequence each time the program is executed. To make the computer produce a different sequence of random numbers each time the program runs, use the function: Randomize() which needs to be executed only once, before the first Rnd() is executed.

Upload: others

Post on 28-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

1

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

The Rnd() function generates random numbers.

Every time Rnd() is executed, it returns a different random fraction (greater than

or equal to 0 and less than 1).

If you end execution and run the program again, you will notice that it produces

the same sequence each time the program is executed.

To make the computer produce a different sequence of random numbers each

time the program runs, use the function: Randomize() which needs to be executed

only once, before the first Rnd() is executed.

Page 2: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

2

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Dim A, B, M As Byte

Dim R As Single

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles Button1.Click

Randomize()

A = Fix(Rnd() * 13) : B = Fix(Rnd() * 13)

Label1.Text = A : Label3.Text = B

TextBox1.Clear() : TextBox1.Focus()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles Button2.Click

R = Val(TextBox1.Text)

M = A * B

If R = M Then

MsgBox("Right Answer")

Else

MsgBox("Wrong Answer ... Right Answer " & M)

End If

End Sub

Page 3: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

3

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button1.Click

Dim X, Y, L, H As Single

Randomize( )

X = Me.Width - PictureBox1.Width

Y = Me.Height - PictureBox1.Height

L = Fix(Rnd( ) * X)

H = Fix(Rnd( ) * Y)

PictureBox1.Left = L

PictureBox1.Top = H

End Sub

End Class

Page 4: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

4

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

The Timer:

It is an invisible stop watch that gives you access to the system clock from the

new designed program.

By the timer we can make events occur after some interval and without the

user intervention.

The Timer properties:

1- Interval: Using it the time interval can be set after which the timer starts. This

interval ranges from (Zero to 65535) milliseconds.

1000 milliseconds = 1 second

2- Enabled: It takes the value (True) or (False) and by which we can start or stop

the timer. The default of this property is (False)

3- Tick Event: It is the event of the timer and when the timer start after the

interval which in interval property. We can write inside the tick event what we

want to be executed automatically after an interval.

Page 5: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

5

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

The datetime Structure:

This structure is in V.B and it contains an extensive list of properties and

methods and when declaring a variable of the “Date” type, then it will be possible

to use the properties and methods of this structure. The following table lists some

of those properties.

Dim S As Date

Property Purpose Example Result

Now Retrieve system date and time X = Now 10/1/2010

10:06:27 PM

Date Date Component X.Date 10/1/2010

Day Day of month (1-31) X.Day 10

DayOfYear Day of year (1-366) X. DayOfYear 10

Hour Hour (0-23) X. Hour 22

Minute Minute (0-59) X. Minute 6

Second Second (0-59) X. Second 27

Month Insert month order through the

year (January) X. Month 1

Page 6: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

6

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Method of the (Datetime) Structure:

1- Add Days : Creates a new date value that is specified numbers of days later

(Or earlier).

2- Add Hours : Creates a new date value that is specified numbers of hours

later (Or earlier).

3- Add Minutes : Creates a new date value that is specified numbers of

Minutes later (Or earlier).

For Example:

Dim H As Date

H.AddHours (-3)

This statements result in creating a new date that is three hours earlier.

Page 7: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

7

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Dim M As Byte

Private Sub Form1_Load(ByVal sender As

System.Object, ByVal e As System.EventArgs) Handles

MyBase.Load

M = 0

End Sub

Private Sub Timer1_Tick(ByVal sender As

System.Object, ByVal e As System.EventArgs) Handles

Timer1.Tick

Label1.Text = TimeOfDay

M = M + 1

If M = 60 Then End

Page 8: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

8

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

End Sub

End Class

Page 9: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

9

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Private Sub Button3_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles Button3.Click

Label1.Text = Now

End Sub

Private Sub Button2_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles Button2.Click

Label1.Text = Today

End Sub

Private Sub Button1_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles Button1.Click

Label1.Text = TimeOfDay

End Sub

Page 10: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

10

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

End Class

Page 11: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

11

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Dim M As Byte

Private Sub Form1_Load(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles MyBase.Load

M = 0

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles Timer1.Tick

Label1.Text = TimeOfDay

M = M + 1

If M = 60 Then End

End Sub

Page 12: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

12

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

End Class

Page 13: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

13

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Page 14: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

14

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Dim X As Integer

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles Timer1.Tick

PictureBox1.Left = PictureBox1.Left + 5

If PictureBox1.Left > X - 10 Then

Timer1.Enabled = False : Timer2.Enabled = True

End If

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles MyBase.Load

X = Me.Width - PictureBox1.Width

Timer1.Enabled = True : Timer2.Enabled = False

End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles Timer2.Tick

PictureBox1.Left = PictureBox1.Left - 5

If PictureBox1.Left < 0 Then

Timer1.Enabled = True : Timer2.Enabled = False

End If

End Sub

End Class

Page 15: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

15

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Dim TR As Byte

Dim SCORE As Integer

Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As

System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown

Button1.Image = PictureBox2.Image

SCORE = SCORE + 1

Label3.Text = SCORE

Page 16: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

16

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

End Sub

Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As

System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp

Button1.Image = PictureBox1.Image

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button4.Click

Dim K As Byte

K = MsgBox("Are you sure ?", MsgBoxStyle.YesNo, "Exit")

If K = vbYes Then End

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button2.Click

Dim K As Byte

Timer1.Enabled = False

K = MsgBox("Do you want to play New Game ?", MsgBoxStyle.YesNo,

"New Game")

If K = vbYes Then

Label5.Hide()

Button1.Left = 0 : Button1.Top = 0

SCORE = 0

' Button2.Enabled = False

Button3.Enabled = True

Button2.Enabled = False

TR = 30

Else

If TR > 0 Then Timer1.Enabled = True

End If

Label2.Text = TR

End Sub

Page 17: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

17

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button3.Click

Button3.Enabled = False

Button1.Enabled = True

Timer1.Enabled = True

Button2.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Timer1.Tick

Button1.Left = Rnd() * (Me.Width - Button1.Width)

Button1.Top = Rnd() * (Me.Height - Button1.Height)

If TR > 0 Then

TR = TR - 1

Label2.Text = TR

End If

If TR = 0 Then

Timer1.Enabled = False

Button1.Enabled = False

Label5.Show()

If SCORE <= 30 Then Label5.Text = "Weak"

If SCORE > 30 And SCORE < 40 Then Label5.Text = "Pass"

If SCORE >= 40 And SCORE < 50 Then Label5.Text = "Good"

If SCORE >= 50 And SCORE < 70 Then Label5.Text = "Very Good"

If SCORE >= 70 Then Label5.Text = "Excellent"

End If

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load

Randomize()

Page 18: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

18

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

End Sub

Public Class Form1

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

PictureBox1.Show()

End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

PictureBox1.Hide()

End Sub

End Class

Page 19: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

19

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Page 20: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

20

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

The reserved word for marks the top of the loop, and the reserved word Next

marks its bottom. The counter is a numeric variable that the programmer provides

and that the loop uses to count iterations. Start, end, and increment are numeric

expressions that the programmer provides. Using the keyword Step is optional. If

you omit it, the counter is incremented by one after each repetition, by default.

When the computer executes the For statement the first time:

The Start numeric value is stored in the variable counter.

The value stored in counter is compared to the ending value end, then

a) If the counter is greater than end, then the computer exits the loop, and

execution resumes at the statement following the reserved word Next.

b) If the counter is less than or equal to end, then the computer executes the

statements inside the loop from top to bottom.

When the computer executes the Next statement, it

1. Increases the value stored in counter by the value of increment. If the keyword

Step is omitted, the counter is incremented by 1.

2. Execution goes back to the top of the loop.

Page 21: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

21

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Examples Using the For…Net Statement

1- Vary the control variable from 5 to 50 with increments of 2

2-Vary the control variable i from 1 to 100 with increments of 1

For i = 1 To 100 Or For i = 1 To 100 Step 1

3- Vary the control variable i from 10 to 2 with increments of -2 (decrements of 2)

For i = 10 To 2 Step -2

4- Vary the control variable i over the sequence 11, 13, 15, 17, and 19

For i = 11 To 19 Step 2

5- Vary the control variable i over the sequence 49, 42, 35, 28, and 21

For i = 49 To 21 Step -7

Page 22: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

22

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Page 23: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

23

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Dim N As Byte

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load

TextBox1.Clear()

For N = 1 To 10

TextBox1.Text = TextBox1.Text & N & vbCrLf

Next

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button1.Click

TextBox2.Clear()

Label2.Text = Button1.Text

For N = 1 To 10 Step 2

TextBox2.Text = TextBox2.Text & N & vbCrLf

Next

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button2.Click

TextBox2.Clear()

Label2.Text = Button2.Text

For N = 2 To 10 Step 2

TextBox2.Text = TextBox2.Text & N & vbCrLf

Next

End Sub

End Class

Page 24: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

24

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Each time the computer encounters DO While, it evaluates the condition.

If the condition is False , execution skips to the first statement following the

reserved word LOOP, as can be seen in Figure 3-2

Figure 3-2

Page 25: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

25

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

As long as the condition is True, the computer executes the statements in the

body of the loop from top to bottom. The reserved word Loop then causes

execution to go back up to the top of the loop where the condition is evaluated

again and then either we exit the loop or we execute the statements in the loop

seen in Figure 3-3

Example (3-1):

The code in Figure 3-4 illustrates the Do While … Loop, where we need to

calculate the sum of all odd integer numbers from 1 to limit where limit is an

integer in txtLimit text box. The corresponding user interface is show in the

Figure 3-5

Figure 3-3

Page 26: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

26

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

The user interface odd numbers application

Figure 3-4

Figure 3-5

Page 27: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

27

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button1.Click

Dim W, T As String

W = "By"

T = ""

Do While T < > W

T = InputBox("Enter any Name")

MsgBox("Welcome " & T)

Loop

End

End Sub

End Class

Page 28: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

28

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Any system in the universe, whether material or virtual needs to follow

main stages to create it or improve its performance, these stages are

summarized as follows:

1. Analysis

2. Design

3. Coding

4. Implementation

5. Maintenance

You can create any software by following stages of the development of

the system (System Development Life Cycle). There are many models that

can be used to do so, and now you can use the model in the following

figure(1).

Page 29: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

29

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Model (1) The System development Life

This model is called "Waterfall Model"

The following table shows these stages.

Terms Other related terms or activities

Analysis Analyze problem and identify system requirements

Design OOP design, Structured design

Implementation Development, construction, testing, installation

Operation Implementation, documentation

Maintenance Perform required modifications to cope with evolution &

Page 30: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

30

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

development and make data backup copies

Q1- Select the appropriate answer of the following:

1 - Follow the steps to solving a specific problem, the first step of the solution are:

(identify the problem - determine output - plan the solution )

2 - Map the flow of flowchart One way to solve the problem of what he called

this step:

(writing program - documentation of the program - plan the solution)

3 - step in which they are required to write code in one of the computer languages

are:

(write a program to - test and debug the program - identify inputs)

4 - Step by step pre-test and debug the program while solving a problem are:

(closer to the program - write a program - determine output)

5 - Last step of solving the problem are:

(deviate output - Write the program - documenting the program)

6 - The first phase of the main stages of the work of any system or improvement

in the performance stage is:

(Design - Implementation - Analysis)

7 - The last phase of the main stages of the work system, oh no improvement in

the performance are:

Page 31: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

31

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

(Analysis - Implementation - Maintenance)

8 - Run the program and enter the necessary data and test results and then the

program is documented in this phase:

(Implementation - Coding - Design)

9 - A study of the problem at hand and know the system requirements in this

phase:

(Analysis - Implementation - Coding)

10 - To develop a method for the work of any system, in that phase:

(Coding - Design - Implementation)

11 - Of the tools used in the implementation of a set of commands automatically

after a certain period of time is the tool:

(Text Box - Timer - ComboBox)

12 - A set of instructions can be executed within the procedure Timer - tick after

a certain period of time to be determined characteristic:

(Interval - Enabled - Name)

13 - The result of command execution (time of day) Msg box gives:

(the current time - the current date - current date and time)

14 - The result of command execution (Today) Msg Box given:

(to the current date - the comment - current date and time)

15 - Can be found by using a random number function:

( Interval - Rnd - Year)

16 - When you use the conditional sentence If .. then .. else if the condition is

met, which between If and Then are executed

Page 32: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

32

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

(phrases Then after that - sentences else after that - before phrases If)

17 - When you use the conditional sentence If .. then .. else if the condition is not

met, which between If and Then are executed:

(phrases Then after that - sentences else after that - before phrases If)

18 - In the sentence "Clock" = me.Text been using the property:

(me - Text - clock)

19 - In the sentence "timer" = me.Text been using the property:

(me - Text - clock)

20 - After the implementation of the sentence Button 1. Enabled = false becomes

the object Button1:

(not available for use - vanished - available for use)

Q2. Put () or (X)

1 - select the input or step of the solution to the problem ( )

2 - Defining the problem, first step of solving any problem ( )

3 - Step by step followed by select inputs determine the output during the solution

of any problem ( )

4 - Step writing program last step of solving any problem ( )

5 - A step closer the program, last step of solving any problem ( )

6 - To develop a method followed by step writing program while

Page 33: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

33

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

solving any problem ( )

7 - Step test and debug the program followed by step writing program while

solving the problem ( )

8 - Maps flow one way to solve the problem ( )

9 - Humor is the first analysis of the key stages of the establishment of this system

or the improvement in performance ( )

10 - In the maintenance phase is the last key stages of the establishment of any

system or improvement in performance ( )

11 - At the stage of documenting the program is correct and test the program( )

12 - In the implementation phase of the program is run and the introduction of the

necessary data and then test the results then are documented program ( )

13 - In the design stage is to run the program and enter the necessary

data and test output ( )

14 - The program is written using the language of the computer in

the appropriate phase code while solving the problem ( )

15 - Maintenance phase precedes the design phase in the initial stages of the

establishment of any system ( )

Page 34: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

34

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Q.3- Complete

Youssef wanted to calculate area of a circle so h wrote the following program:

Const Pi As Single = 3.14

Dim R As Single

Dim Area As Double

R = 1000

Area = Pi * R * R

MsgBox( Area )

1. Youssef used the numeric variable R of type ……….. to store the value

………

2. He used also numeric constant …..… of the data type single to store the value

…...

3. Youssef used the numeric variable …………….… of data type

……….……..to store ………………..… which is equal to Pi*R2.

4. Numeric variable was declared using the keyword (Dim), the constant Pi was

declared using the keyword ……………..….

Page 35: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

35

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Q.4 - Choose the correct answer:

(Dim, Const, String, Single)

1. Khaled wanted to calculate total grade of a student so he declared numeric

variables using the word……………….

2. He used a variable of data type ……………..…. To store student name.

3. He used a variable of data type………………….… to store the total grade.

Q5. : Put ( √ ) or ( × )

1-Add It's possible to control the intervals of the "Timer" firing through

the "Interval property" ( )

2-One second is equal 100 milliseconds ( )

3-The determined interval in " Interval property " ranges from

(zero, 6500) milliseconds ( )

4-By " Enabled " property of the timer the "Timer" runs or stops it after putting it

on the "Form window" ( )

5-When "Enable property" takes "True" value, this prevents "Tick event" from

occurring and stops the "Timer" ( )

6-To control " Enable property " and give it (True or False) values, that should be

during designing and that can't be controlled during running ( )

7- To use (DateTime) structure and its properties and method we should first

declare a variable of the “Date” type. ( )

Page 36: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

36

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Q6- What is the term which the following sentences indicate:

1- It is a property which means the duration in which the timer is activated and

when it is activated “Tick” event occurs. (……………..)

2- An event of the timer and it occurs when activating (starting) the timer and we

write inside the statements which need to be executed

after on interval. (……………..)

3- An invisible object which helps us in our dealing with the operating

system clock. (……………..)

4- It has a number of properties and methods which control the time and they may

be used when declaring a variable of the “Date” type. (……………..)

Q7- Choose from the second column the suitable for the first column:

Column (1) Column (2)

1 Second (……) A Insert the Month order during the year.

2 Day (……) B Insert the current second.

3 Now (…….) C Insert the Day order during the year.

4 Minutes (……) D Insert the current minute.

5 Date (……) E Insert the Day order during the month.

6 Month (…….) F Occurs after the specified interval and the

statements in it are executed.

7 Enabled (……) G Insert the current date and time.

8 Tick (……) H

Responsible for determining the duration after

which the timer starts and is measure with the

millisecond

9 DateOfYear(…….) J Insert the current Date.

10 Interval (……) K For starting or stopping the timer.

Page 37: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

37

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Q8. : Multiple choices Question:-

1- Timer property Interval sets the rate at Tick events occur in

…………………

a) Seconds b) Milliseconds

c) Minute d) Hour

2- Timer property “Interval” property sets the rate at which tick events occur in

………

a. Second b. Minute. c. Millisecond. d. Hour

3- If “Interval value” is 3000, then its value in seconds is:

a. 3 b. 30 c. 3000 d. 300

4- The ………….. structure retrieves your computer’s date and time.

a. Current Time b. Time c. Now d. DateTime

5- You can ……………. To a date variable.

a. Add day’s b. Add hour’s c. Subtract days d. All of the

above

6- To subtract one day from Date variable X, assign the value returned by

……….. to X.

a. X.AddHours (-24)

b. X.SubtractDays

c. X.AddHours (-1)

Page 38: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

38

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

d. a and c

Q9. Choose the correct answer for each one of the following:

1- In For … Next statement, the number of repetition in For X=1 to 8 step 3 is

……………

(a) 3 (b) 4

(c) 2 (d) 1

2- The property Interval for the (Timer) sets the rate at which the event occurs

in ……………

(a) Second. (b) Minute.

(c) Millisecond. (d) Hour.

3 - We can stop the timer by giving the property --------- the value false

(a) Interval. (b) Enabled.

(c) Modifiers (d) Tag

4- The Numeric Variable which takes integer numbers from 0 to 255 is

……………..

(a) Integer. (b) String.

(c) Byte. (d) Double.

Page 39: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

39

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

Q10.Complete the following statements from the words between

brackets:

1- To prevent the (Timer1) from running, you write the command "

Timer1.enabled = ……………..…"

End ) – False – True )

2- In (If…Then…Else… ) statement, when the outcome of the condition is

evaluated to be ……………. then the statements following (Else) are executed

Null ) – False – True )

3- You can find out the date and time in the computer by executing the

command MsgBox (... ... ....)

DateTime ) – Time – Now )

4- To delete all items from the object (listbox1), we use the method.................

Delete ) – Clear – Remove )

Q11. Complete the following statements from the words between

brackets.

(Dim – Const – String - Single - Class – Object)

Khaled wants to write program codes to compute the total degrees of a student in

all subjects, and

1-he uses numerical variable of type Single which is declared by the term (……)

2-he uses also a variable type (…………) to store student name value.

Page 40: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

40

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

3-he uses a variable of type (……………) to store the total degrees of the student

in all subjects.

Q12.

A) Read the following instructions

Dim Age , Mark , Total As Single

Age = 25.5

Mark = 90

If Age < 26 Then

Age = 16

Mark=100

End If

Total = Mark * 2

B) Execute the previous instructions ,then choose the correct answers

from the following:

1. The value of the variable "Age" is:

a- 25.5 b - 90 c - 16

2. The value of the variable "Mark" is:

a – 90 b-100 c-25.5

3. The result of the condition Age < 26 :

a – 25.5 b- True c-False

Page 41: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

41

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

4. The value of the variable "Total" is:

a – 200 b- 180 c- 190

Q13-Put a tick () in front of the true sentence and a cross (X) in

front of the wrong sentence:

1- The variable name "Spent_Money" is a valid name in terms of rules of naming

variables. ( )

2- The For…Next Loop is used when we know in advance the number of

iterations of the loop. ( )

3-In a program, lines that begin with ('), are considered comments within the

program code. ( )

4-Variable of type Double is used to store integers only ( )

5-To clear the ListBox control from all items, the method Remove (text)

is used. ( )

Q14

a- Read the following code:

Dim X , Y , Z As Integer

X = 2

Y = 3

Z = 4

MsgBox ( Y^X * X + Z * 3 )

Page 42: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

42

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

And then type the result of the execution :

...........................................................

b- Read the following code:

Dim X , C As Integer

X = 4

For C = 0 To 7 Step 3

X = X * 2

Next

MsgBox ( X )

What is the value of x in the message box ? ................................

Q15-Write the scientific term for each phrase of the following

statements:

A- Method used to delete all items of the ListBox control is (………….…..).

B- Tool that allows programmers to divide a number of RadioButtons and

CheckBoxes into different groups. (……….……..).

Page 43: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

43

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

C- Tool that allows you to create or display a list of items (………….…..).

Q.16: Match from the First column with the suitable in the second

column:

From the properties of “Check Box”

Property Function

1 Appearance (….) 1 Set the width of the control

2 Width (….) 2 Changes the button from into the default

3 Enabled (….) 3 Sets and puts image on the control

4 Image (….) 4 Determines whether to choose the control or not

(True or False)

5 Checked (….) 5 Runs or stops the control

Q.17: Put (√) or (X)

1- To store a numeric statement in a variable, this variable could be

named (1 Number) ( )

2- Colors are from the examples of the intrinsic constants in VB. ( )

Page 44: Computer (Sec .1) Mr.Khaled Anwar (01003340348) · 2018-02-01 · 1 Mr.Khaled Anwar (01003340348) Computer (Sec .1) Second Term The Rnd() function generates random numbers. Every

44

Mr.Khaled Anwar (01003340348) Computer (Sec.1)

Second Term

3- Byte means the equal sized bytes which determine the size of the

computer memory ( )

4- “Interval” property of the “timer” determines the average of tick event of the

occurrence and the value of this property could be measured by minutes( )

The compound condition “And” takes the “true” value if one of the conditions is

“True” and not both of them ( )

Q18. : Choose the correct answer:

1- Giving that X = 3 , Y = 2 , then the result of (X ^ Y + 3 * 2) is ……….

( 20 - 16 - 15 )

2- To remove all the items in the Listbox, use the method …………….

(Clear – Delete – remove)

3- You can add by …………. An item in the end of the program,

(Add – Insert – Count)

4- The code ……….. is used for the integer division.

( Mod - \ - / )