مقدمة في البرمجة Lecture 7
Write VB.net project using the for loop to calculate : 1- the sum of numbers from 1 to (A) numbers. 2- the sum of Odd numbers from 1 to (A) numbers. 3- the sum of Even numbers from 1 to (A) numbers. ** (A : any number input by user).
Create an Interface, Change properties:
Write a code : Double click on : 1- Button 1 : Dim i, a, x as integer a = Val(textbox1.text) x=0 For i =1 to a x= x + i Next i Textbox2.text = x
Write a code : Double click on : 2- Button 2 : Dim i, a, x as integer a = Val(textbox1.text) x=0 For i =1 to a step 2 x= x + i Next i Textbox3.text = x
Write a code : Double click on : 3- Button 3 : Dim i, a, x as integer a = Val(textbox1.text) x=0 For i =0 to a step 2 x= x + i Next i Textbox4.text = x
Write a code : Double click on : 4- Button 4 : Textbox1.text = “ “ Textbox2.text = “ “ Textbox3.text = “ “ Textbox4.text = “ “
Execute a program: - Input a number :
Execute a program: - When we Click on The sum of numbers button, the result will appear :
Execute a program: - When we Click on The sum of odd numbers button, the result will appear :
Execute a program: - When we Click on The sum of even numbers button, the result will appear :
Execute a program: - When we Click on Delete button, all textboxes will be clean:
Write VB.net project using the Do / While loop to calculate : 1- the sum of numbers from 1 to (A) numbers. 2- the sum of Odd numbers from 1 to (A) numbers. 3- the sum of Even numbers from 1 to (A) numbers. ** (A : any number input by user).
Create an Interface, Change properties:
Write a code : Double click on : 1- Button 1 : Dim i, a, x as integer a = Val(textbox1.text) x=0 i = 1 Do while i <= a x= x + i i = i +1 loop Textbox2.text = x
Write a code : Double click on : 2- Button 2 : Dim i, a, x as integer a = Val(textbox1.text) x=0 i = 1 Do while i <= a x= x + i i = i +2 loop Textbox3.text = x
Write a code : Double click on : 3- Button 3 : Dim i, a, x as integer a = Val(textbox1.text) x = 0 i = 0 Do while i <= a x= x + i i = i +2 loop Textbox4.text = x
Write a code : Double click on : 4- Button 4 : Textbox1.text = “ “ Textbox2.text = “ “ Textbox3.text = “ “ Textbox4.text = “ “
Execute a program: - Input a number :
Execute a program: - When we Click on The sum of numbers button, the result will appear :
Execute a program: - When we Click on The sum of odd numbers button, the result will appear :
Execute a program: - When we Click on The sum of even numbers button, the result will appear :
Execute a program: - When we Click on Delete button, all textboxes will be clean:
Write VB.net project using the Do Until Loop to calculate : 1- the sum of numbers from 1 to (A) numbers. 2- the sum of Odd numbers from 1 to (A) numbers. 3- the sum of Even numbers from 1 to (A) numbers. ** (A : any number input by user).
Create an Interface, Change properties:
Write a code : Double click on : 1- Button 1 : Dim i, a, x as integer a = Val(textbox1.text) x=0 i = 1 Do Until i > a x= x + i i = i +1 loop Textbox2.text = x
Write a code : Double click on : 2- Button 2 : Dim i, a, x as integer a = Val(textbox1.text) x=0 i = 1 Do Until i > a x= x + i i = i +2 loop Textbox3.text = x
Write a code : Double click on : 3- Button 3 : Dim i, a, x as integer a = Val(textbox1.text) x=0 i = 0 Do Until i > a x= x + i i = i +2 loop Textbox4.text = x
Write a code : Double click on : 4- Button 4 : Textbox1.text = “ “ Textbox2.text = “ “ Textbox3.text = “ “ Textbox4.text = “ “
Execute a program: - Input a number :
Execute a program: - When we Click on The sum of numbers button, the result will appear :
Execute a program: - When we Click on The sum of odd numbers button, the result will appear :
Execute a program: - When we Click on The sum of even numbers button, the result will appear :
Execute a program: - When we Click on Delete button, all textboxes will be clean: