Pages

lunes, 4 de marzo de 2013

hallar la suma de los 20 primeros numeros pares Visual Basic - VB

Problema
Hacer un programa que permita hallar la suma de los 20 primeros numeros

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim sum As Integer = 0
        Dim cad As String = ""
        For i As Integer = 2 To 40 Step 2
            cad = cad + Trim(i) + " "
            sum = sum + i
        Next i
        TextBox1.Text = cad
        TextBox2.Text = Trim(sum / 20)
    End Sub
End Class

No hay comentarios:

Publicar un comentario