Dim i, n, s, a, k As Double

Private Sub TextBox1_Change() /N:okno wsprowadzania danych/

n = Val(TextBox1.Text)

TextBox2.Text = " "

End Sub

SUMA N WYRAZÓW Z CIĄGU

Private Sub CommandButton1_Click()

s = 0

For i = 1 To n

s = s + Cells(i, 1)

Next i

TextBox2.Text = s

End Sub

MNOŻY CO DRUGĄ LICZBĘ CIĄGU

Private Sub CommandButton5_Click()

s = 1

For i = 1 To n Step 2

s = s * Cells(i, 1)

Next i

TextBox2.Text = s

End Sub

LICZY ŚREDNIĄ Z N LICZB CIĄGU

Private Sub CommandButton3_Click()

s = 0

For i = 1 To n

s = s + Cells(i, 1)

Next i

s = s / n

TextBox2.Text = s

End Sub

SUMUJE CO DRUGĄ LICZBĘ Z CIĄGU

Private Sub CommandButton4_Click()

s = 0

For i = 2 To n Step 2

s = s + Cells(i, 1)

Next i

TextBox2.Text = s

End Sub

MNOŻY N LICZB Z CIĄGU

Private Sub CommandButton2_Click()

s = 1

For i = 1 To n

s = s * Cells(i, 1)

Next i

TextBox2.Text = s

End Sub

ZNAJDUJE NAJWIĘKSZĄ LICZBĘ Z CIĄGU

Private Sub CommandButton7_Click()

s = 0

k = 0

For i = 1 To n

a = Cells(i, 1)

If a Mod 2 = 1 Then

s = s + Cells(i, 1)

k = k + 1

Else

s = s

End If

Next i

If k <> 0 Then

s = s / k

TextBox2.Text = s

Else

TextBox2.Text = "brak nieparzystych"

End If

End Sub

ILOCZYN LICZB PARZYSTYCH Z CIĄGU

Private Sub CommandButton6_Click()

s = 1

For i = 1 To n

a = Cells(i, 1)

If a Mod 2 = 0 Then

s = s * Cells(i, 1)

Else

s = s

End If

Next i

TextBox2.Text = s

End Sub

ŚREDNIA LICZB NIEPARZYSTYCH Z CIĄGU

Private Sub CommandButton7_Click()

s = 0

k = 0

For i = 1 To n

a = Cells(i, 1)

If a Mod 2 = 1 Then

s = s + Cells(i, 1)

k = k + 1

Else

s = s

End If

Next i

If k <> 0 Then

s = s / k

TextBox2.Text = s

Else

TextBox2.Text = "brak nieparzystych"

End If

End Sub

ZNAJDUJE NAJMNIEJSZĄ PARZYSTĄ Z CIĄGU

Dim n, i, x, k, a, t(10), b As Double

Private Sub CommandButton1_Click()

i = 1

k = 0

a = 0

Do Until k = 1

If Cells(i, 1) Mod 2 = 0 Then

x = Cells(i, 1)

k = 1

Else

i = i + 1

If i > n Then

x = "Brak liczb parzystych w zakresie"

k = 1

End If

End If

Loop

For k = i To n

If Cells(k, 1) < x And Cells(k, 1) Mod 2 = 0 Then

x = Cells(k, 1)

a = a + 1

End If

Next k

TextBox2.Text = x

End Sub