Skip to content

Instantly share code, notes, and snippets.

@YamilG
Created February 3, 2012 19:06
Show Gist options
  • Save YamilG/1731797 to your computer and use it in GitHub Desktop.
Save YamilG/1731797 to your computer and use it in GitHub Desktop.
Examen ejercicio 1
Public Class Form1
Dim tarifaA As Integer = 400
Dim tarifaB As Integer = 430
Dim tarifaC As Integer = 450
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tarifa.Items.Add("Tarifa A")
tarifa.Items.Add("Tarifa B")
tarifa.Items.Add("Tarifa C")
tarifa.SelectedIndex = 2
End Sub
Private Sub limpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles limpiar.Click
cantidad.Text = ""
nombre.Text = ""
End Sub
Private Sub comprar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comprar.Click
If Val(cantidad.Text) > 0 And nombre.Text <> "" Then
Dim subTotal As Double = Val(cantidad.Text)
totalNombre.Text = nombre.Text
If tarifa.SelectedIndex = 0 Then
subTotal = subTotal * tarifaA
totalSubtotal.Text = subTotal
ElseIf tarifa.SelectedIndex = 1 Then
subTotal = subTotal * tarifaB
totalSubtotal.Text = subTotal
Else
subTotal = subTotal * tarifaC
totalSubtotal.Text = subTotal
End If
Dim impuesto As Double = subTotal * 0.12
totalImpuesto.Text = impuesto
Dim total As Double = subTotal + impuesto
totalTotal.Text = total
Else
MessageBox.Show("Por favor rellene todos los espacios")
If cantidad.Text = "" Then
cantidad.Focus()
Else
nombre.Focus()
End If
End If
End Sub
Private Sub guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles guardar.Click
If totalNombre.Text = "" Or totalImpuesto.Text = "" Or totalSubtotal.Text = "" Or totalTotal.Text = "" Then
MessageBox.Show("No se pueden guardar valores vacios")
ElseIf listaClientes.Items.Count > 9 Then
MessageBox.Show("Has alcanzado el limite de clientes por guardar")
Else
listaClientes.Items.Add(totalNombre.Text)
guardadoCounter.Text = listaClientes.Items.Count & "/10"
End If
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment