domingo, 27 de septiembre de 2015

VB.Net 2010 - Windows Form - Arreglo de ventas


Solución

Imagen:






Código:

Public Class Form1
    'El arreglo "matriz" es para almacenar los meses
    Dim matriz(12) As String
    'El arreglo "ventas" es para almacenar las ventas
    Dim ventas(12) As Double
    Dim a As Double = 0
    Dim i As Double = 0
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Cargar matriz
        matriz(0) = "Enero"
        matriz(1) = "Febrero"
        matriz(2) = "Marzo"
        matriz(3) = "Abril"
        matriz(4) = "Mayo"
        matriz(5) = "Junio"
        matriz(6) = "Julio"
        matriz(7) = "Agosto"
        matriz(8) = "Septiembre"
        matriz(9) = "Octubre"
        matriz(10) = "Noviembre"
        matriz(11) = "Diciembre"

        TextBox1.Text = matriz(a)
    End Sub

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        If e.KeyChar = Chr(13) Then
            If a <> 12 Then
                ventas(i) = TextBox2.Text
                TextBox2.Clear()
                a += 1
                i += 1
                If a = 12 Then
                    TextBox1.Clear()
                    TextBox2.Clear()
                    TextBox1.Enabled = False
                    TextBox2.Enabled = False
                End If
                TextBox1.Text = matriz(a)
            End If
        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim j As Double

        For j = 0 To 11
            ListBox1.Items.Add(ventas(j))
        Next
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim max, j As Double
        Dim mes As String

        max = ventas(0)
        For j = 1 To 11
            If ventas(j) > max Then
                max = ventas(j)
                mes = matriz(j)
            End If
        Next

        TextBox3.Clear()
        TextBox3.Text = mes
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim max, j As Double

        max = ventas(0)
        For j = 1 To 11
            If ventas(j) > max Then
                max = ventas(j)
            End If
        Next

        TextBox3.Clear()
        TextBox3.Text = "$ " & max
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim suma, j As Double
        suma = 0

        For j = 0 To 11
            suma = suma + ventas(j)
        Next

        TextBox3.Clear()
        TextBox3.Text = "$ " & suma
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim prom, suma, j As Double
        suma = 0

        For j = 0 To 11
            suma = suma + ventas(j)
        Next

        prom = suma / i

        TextBox3.Clear()
        TextBox3.Text = "$ " & prom
    End Sub
End Class



==>DESCARGAR<==

No hay comentarios:

Publicar un comentario

Cambiar imagen de fondo con JQuery

<!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>Cambiar ...