You are on page 1of 5

Imports System.Data.

OleDb

Public Class Form1


Dim dt As New DataTable
Dim cn As New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Tobi\Cajero\Cajero.mdb")

Private Sub cmdCalcular_Click(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles cmdCalcular.Click
Dim x As Integer
Dim Dinero As Integer = Int(txtCantidad.Text)

For x = 0 To (Dinero / 500) - 1


Dinero = Dinero - 500
Next x
txt500.Text = x

For x = 0 To (Dinero / 200) - 1


Dinero = Dinero - 200
Next x
txt200.Text = x

For x = 0 To (Dinero / 100) - 1


Dinero = Dinero - 100
Next x
txt100.Text = x

For x = 0 To (Dinero / 50) - 1


Dinero = Dinero - 50
Next x
txt50.Text = x

For x = 0 To (Dinero / 20) - 1


Dinero = Dinero - 20
Next x
txt20.Text = x

x = Int(txtCantidad.Text)
Dim Mensaje As String = " "

If (x >= 9000) And (x <= 9999) Then


Mensaje = Mensaje & "nuevemil "
x = x - 9000
End If

If (x >= 8000) And (x <= 8999) Then


Mensaje = Mensaje & "ochomil "
x = x - 8000
End If

If (x >= 7000) And (x <= 7999) Then


Mensaje = Mensaje & "sietemil "
x = x - 7000
End If

If (x >= 6000) And (x <= 6999) Then


Mensaje = Mensaje & "seismil "
x = x - 6000
End If
If (x >= 5000) And (x <= 5999) Then
Mensaje = Mensaje & "cincomil "
x = x - 5000
End If

If (x >= 4000) And (x <= 4999) Then


Mensaje = Mensaje & "cuatromil "
x = x - 4000
End If

If (x >= 3000) And (x <= 3999) Then


Mensaje = Mensaje & "tresmil "
x = x - 3000
End If

If (x >= 2000) And (x <= 2999) Then


Mensaje = Mensaje & "dosmil "
x = x - 2000
End If

If (x >= 1000) And (x <= 1999) Then


Mensaje = Mensaje & "mil "
x = x - 1000
End If

If (x >= 900) And (x <= 999) Then


Mensaje = Mensaje & "novecientos "
x = x - 900
End If

If (x >= 800) And (x <= 899) Then


Mensaje = Mensaje & "ochocientos "
x = x - 800
End If

If (x >= 700) And (x <= 799) Then


Mensaje = Mensaje & "setecientos "
x = x - 700
End If

If (x >= 600) And (x <= 699) Then


Mensaje = Mensaje & "seiscientos "
x = x - 600
End If

If (x >= 500) And (x <= 599) Then


Mensaje = Mensaje & "quinientos "
x = x - 500
End If

If (x >= 400) And (x <= 499) Then


Mensaje = Mensaje & "cuatrocientos "
x = x - 400
End If

If (x >= 300) And (x <= 399) Then


Mensaje = Mensaje & "trescientos "
x = x - 300
End If

If (x >= 200) And (x <= 299) Then


Mensaje = Mensaje & "doscientos "
x = x - 200
End If

If (x >= 100) And (x <= 199) Then


Mensaje = Mensaje & "cien "
x = x - 100
End If

If (x >= 90) And (x <= 99) Then


Mensaje = Mensaje & "Noventa"
x = x - 90
End If

If (x >= 80) And (x <= 89) Then


Mensaje = Mensaje & "ochenta "
x = x - 80
End If

If (x >= 70) And (x <= 79) Then


Mensaje = Mensaje & "setenta"
x = x - 70
End If

If (x >= 60) And (x <= 69) Then


Mensaje = Mensaje & "sesenta"
x = x - 60
End If

If (x >= 50) And (x <= 59) Then


Mensaje = Mensaje & "cincuenta"
x = x - 50
End If

If (x >= 40) And (x <= 49) Then


Mensaje = Mensaje & "cuarenta"
x = x - 40
End If

If (x >= 30) And (x <= 39) Then


Mensaje = Mensaje & "treinta"
x = x - 30
End If

If (x >= 20) And (x <= 29) Then


Mensaje = Mensaje & "veinte"
x = x - 20
End If

cn.Open()
Dim GuardarDatos As String = "Insert Into
Dinero(Dinero,500,200,100,50,20,Mensaje)" & "Values ('" &
txtCantidad.Text & "','" & txt500.Text & "','" & txt200.Text & "','" &
txt100.Text & "','" & txt50.Text & "','" & txt20.Text & "','" &
Mensaje & "')"
Dim DataAdapter As New OleDb.OleDbDataAdapter(GuardarDatos,
cn)
DataAdapter.Fill(dt)
MsgBox(Mensaje & vbCrLf & "Se agrego correctamente el
registro", MsgBoxStyle.Information, "Mensaje")
DataAdapter.Dispose()
cn.Close()
End Sub

Private Sub cmdLimpiar_Click(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles cmdLimpiar.Click
txtCantidad.Text = ""
txt500.Text = ""
txt200.Text = ""
txt100.Text = ""
txt50.Text = ""
txt20.Text = ""
End Sub
End Class

You might also like