domingo, 1 de marzo de 2015

Aplicacion de windows form simular un cajero automatico


Public Class Form1
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Label1.Text = Label1.Text & numeroCuenta
        Label2.Text = Label2.Text & saldoActual
    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If RadioButton1.Checked Then
            If IsNumeric(TextBox1.Text) And Val(TextBox1.Text) > 0 Then
                deposito(TextBox1.Text)
                Label2.Text = "Saldo actual: " & saldoActual
            Else
                MsgBox("Escriba una cantidad positiva")
                TextBox1.Clear()
                TextBox1.Focus()
            End If
        Else
            If IsNumeric(TextBox1.Text) And Val(TextBox1.Text) > 0 Then
                Label2.Text = "Saldo actual: " & retiro(TextBox1.Text)
            Else
                MsgBox("Escriba una cantidad positiva")
                TextBox1.Clear()
                TextBox1.Focus()
            End If
        End If
    End Sub
End Class

PONER EN UN MODULO EL SIGUIENTE  CÓDIGO
Module Module1
    Public numeroCuenta As String = "763846238"
    Public saldoActual As Decimal = 1200

    Sub deposito(cantidad As Decimal)
        If cantidad > 0 Then
            saldoActual = saldoActual + cantidad
        End If
    End Sub

    Function retiro(cantidad As Decimal) As Decimal
        If cantidad > 0 And cantidad <= saldoActual Then
            saldoActual = saldoActual - cantidad
        End If
        Return saldoActual
    End Function

End Module

No hay comentarios:

Publicar un comentario