lunes, 2 de marzo de 2015

APLICACION PARA SUMAR DOS AREGLOS EN VB.NET

Public Class Form1
    Dim r As New Random
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim a(9) As Integer
        Dim b(9) As Integer
        ListBox1.DataSource = llenarArreglo(a)
        ListBox2.DataSource = llenarArreglo(b)
        ListBox3.DataSource = sumarArreglos(a, b)
    End Sub
    Function llenarArreglo(ByRef c() As Integer) As Array
        For i = 0 To c.GetUpperBound(0)
            c(i) = r.Next(10, 99)
        Next
        Return c
    End Function
    Function sumarArreglos(x() As Integer, y() As Integer) As Array
        Dim c(0) As Integer
        If x.Length = y.Length Then
            ReDim c(x.GetUpperBound(0))
            For i = 0 To x.GetUpperBound(0)
                c(i) = x(i) + y(i)
            Next
        End If
        Return c
    End Function
End Class

No hay comentarios:

Publicar un comentario