You are on page 1of 2

6.Sa se afle suma numerelor pare dintr-un vector.

Codul sursa este urmatorul:


Public Class Form1
Dim n As Integer
Dim v(100) As Integer
Dim i As Integer
Dim s As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
n = TextBox1.Text
For i = 1 To n
v(i) = InputBox("Introduceti valoarea " + Str(i))
Next
s = 0

For i = 1 To n
If v(i) Mod 2 = 0 Then
s = s + v(i)
End If
Next
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


RichTextBox1.AppendText("suma valorilor pare este " + Str(s))
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub
End Class

You might also like