VERSION 5.00
Begin VB.Form frmVuelto 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Pago en Efectivo"
   ClientHeight    =   5415
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5355
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5415
   ScaleWidth      =   5355
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdCalcular 
      Caption         =   "Ca&lcular"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   600
      TabIndex        =   13
      Top             =   4680
      Width           =   1215
   End
   Begin VB.CommandButton cmdSalir 
      Cancel          =   -1  'True
      Caption         =   "&Salir"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   3240
      TabIndex        =   15
      Top             =   4680
      Width           =   1215
   End
   Begin VB.CommandButton cmdAceptar 
      Caption         =   "&Aceptar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1920
      TabIndex        =   14
      Top             =   4680
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Height          =   4545
      Left            =   90
      TabIndex        =   4
      Top             =   30
      Width           =   5160
      Begin VB.TextBox txtTotalDolares 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   15.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   3060
         Locked          =   -1  'True
         TabIndex        =   3
         TabStop         =   0   'False
         Top             =   930
         Width           =   1950
      End
      Begin VB.TextBox txtEfectivoDolares 
         Alignment       =   1  'Right Justify
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   15.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   3060
         TabIndex        =   8
         Top             =   2310
         Width           =   1950
      End
      Begin VB.TextBox txtVueltoDolares 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   15.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   3060
         TabIndex        =   10
         Top             =   3660
         Width           =   1950
      End
      Begin VB.TextBox txtVuelto 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   15.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   3060
         Locked          =   -1  'True
         TabIndex        =   12
         TabStop         =   0   'False
         Top             =   3090
         Width           =   1950
      End
      Begin VB.TextBox txtEfectivo 
         Alignment       =   1  'Right Justify
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   15.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   3060
         TabIndex        =   6
         Top             =   1740
         Width           =   1950
      End
      Begin VB.TextBox txtTotal 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00C0FFFF&
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   15.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   3060
         Locked          =   -1  'True
         TabIndex        =   1
         TabStop         =   0   'False
         Top             =   375
         Width           =   1950
      End
      Begin VB.Label Label3 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Total(U$):"
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   17.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   855
         TabIndex        =   2
         Top             =   1005
         Width           =   2220
      End
      Begin VB.Label Label2 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Efectivo(&U$):"
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   17.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   225
         TabIndex        =   7
         Top             =   2370
         Width           =   2850
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "&Vuelto(U$):"
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   17.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   645
         TabIndex        =   9
         Top             =   3735
         Width           =   2430
      End
      Begin VB.Label lblVuelto 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Vuelto(S/.):"
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   17.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   435
         TabIndex        =   11
         Top             =   3180
         Width           =   2640
      End
      Begin VB.Label lblTotal 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Total(S/.):"
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   17.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   645
         TabIndex        =   0
         Top             =   465
         Width           =   2430
      End
      Begin VB.Label lblEfectivo 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Efectivo(&S/.):"
         BeginProperty Font 
            Name            =   "Courier New"
            Size            =   17.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   30
         TabIndex        =   5
         Top             =   1830
         Width           =   3045
      End
   End
End
Attribute VB_Name = "frmVuelto"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public iTipoVenta As Integer

Private Sub cmdAceptar_Click()
  If EsValido = True Then
      If CDbl(txtEfectivo.Text) <= 0 And CDbl(txtEfectivoDolares.Text) <= 0 Then
         txtEfectivo.Text = txtTotal.Text
      End If
      frmCajaRegistradora.iEfectivo = Val(Format(CStr(txtEfectivo.Text), "###########0.00"))
      frmCajaRegistradora.iEfectivoDolares = Val(Format(CStr(txtEfectivoDolares.Text), "###########0.00"))
      frmCajaRegistradora.iVuelto = Val(Format(CStr(txtVuelto.Text), "###########0.00"))
      frmCajaRegistradora.iVueltoDolares = Val(Format(CStr(txtVueltoDolares.Text), "###########0.00"))
      
    '  If iTipoVenta = 3 Then
    '    frmCajaRegistradora.iVuelto = Val(Format(CStr(txtVueltoSoles.Text), "###########0.00"))
    '  Else
    '    frmCajaRegistradora.iVuelto = Val(Format(CStr(txtVuelto.Text), "###########0.00"))
    '  End If
    
      frmCajaRegistradora.bVuelto = True
      Unload Me
  End If
End Sub

Private Function EsValido() As Boolean

    EsValido = True
    
    If Val(txtEfectivo.Text) < 0 Or _
       Val(txtEfectivoDolares.Text) < 0 Or _
       Val(txtVuelto.Text) < 0 Or _
       Val(txtVueltoDolares) < 0 Then
       
       EsValido = False
       MsgBox "No pueden existir montos negativos"
       Exit Function
    End If
    
End Function

Private Sub cmdCalcular_Click()
  Call CalculoVuelto
End Sub

Private Sub cmdSalir_Click()
  Unload Me
End Sub

Private Sub Form_Load()
   txtTotal.Text = Format(CStr(frmCajaRegistradora.iTotalVenta), "###,###,###,##0.00")
   txtTotalDolares.Text = Format(CStr(frmCajaRegistradora.iTotalVenta / nTipoCambio), "###,###,###,##0.00")
   
   txtEfectivo.Text = Format(txtTotal.Text, "###,###,###,##0.00")
   txtEfectivoDolares.Text = Format(CStr(0), "###,###,###,##0.00")
   
   txtVuelto.Text = Format(CStr(0), "###,###,###,##0.00")
   txtVueltoDolares.Text = Format(CStr(0), "###,###,###,##0.00")
      
   If iTipoVenta = 3 Then
     'txtTotal.Text = Format(CStr(frmCajaRegistradora.iTotalVenta / nTipoCambio), "###,###,###,##0.00")
     'Me.Caption = "Pago en Dólares (TC: U$ " + Format(nTipoCambio, "###,###,###,##0.00") + ")"
     'lblTotal.Caption = "Total(U$):"
     'lblEfectivo.Caption = "Efectivo(U$):"
     'lblVuelto.Caption = "Vuelto(U$):"
   End If
   Me.txtEfectivo.Tag = "0"
   txtEfectivo.SelStart = 0
   txtEfectivo.SelLength = Len(txtEfectivo.Text)
End Sub
Private Sub txtEfectivo_GotFocus()
  txtEfectivo.SelStart = 0
  txtEfectivo.SelLength = Len(txtEfectivo.Text)
End Sub
Private Sub txtEfectivo_LostFocus()
  txtEfectivo.Tag = "1"
  CalculoVuelto
End Sub
Private Sub txtEfectivoDolares_GotFocus()
  txtEfectivoDolares.SelStart = 0
  txtEfectivoDolares.SelLength = Len(txtEfectivoDolares.Text)
End Sub
Private Sub txtVueltoDolares_GotFocus()
  txtVueltoDolares.SelStart = 0
  txtVueltoDolares.SelLength = Len(txtVueltoDolares.Text)
End Sub
Private Sub txtEfectivo_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then
        txtEfectivo_LostFocus
    End If
End Sub
Private Sub txtEfectivoDolares_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then
        txtEfectivoDolares_LostFocus
  End If
End Sub
Private Sub txtVueltoDolares_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then
        txtVueltoDolares_LostFocus
    End If
End Sub
Private Sub txtEfectivoDolares_LostFocus()
    txtVuelto.Text = "0.00"
    txtEfectivoDolares.Tag = "1"
    CalculoVuelto
    txtEfectivoDolares.Tag = "0"
    txtEfectivo.SetFocus
    txtEfectivo.SelStart = 0
    txtEfectivo.SelLength = Len(Me.txtEfectivo.Text)
End Sub
Private Sub txtVueltoDolares_LostFocus()
  txtVueltoDolares.Tag = "1"
  txtVuelto.Text = "0.00"
  Call CalculoVuelto
  txtVueltoDolares.Tag = "0"
  txtEfectivo.SelStart = 0
  txtEfectivo.SelLength = Len(txtEfectivoDolares.Text)
  txtEfectivo.SetFocus
End Sub
Private Sub txtEfectivo_KeyPress(KeyAscii As Integer)
   On Error GoTo LineaError
   Call ValidKeyPress(KeyAscii, kVKP_NUMERIC_ONLY)
   Exit Sub
LineaError:
   MsgBox Err.Description, vbOKOnly + vbInformation
End Sub
Private Sub txtEfectivoDolares_KeyPress(KeyAscii As Integer)
   On Error GoTo LineaError
   Call ValidKeyPress(KeyAscii, kVKP_NUMERIC_ONLY)
   Exit Sub
LineaError:
   MsgBox Err.Description, vbOKOnly + vbInformation
End Sub
Private Sub txtVueltoDolares_KeyPress(KeyAscii As Integer)
   On Error GoTo LineaError
   Call ValidKeyPress(KeyAscii, kVKP_NUMERIC_ONLY)
   Exit Sub
LineaError:
   MsgBox Err.Description, vbOKOnly + vbInformation
End Sub
Sub CalculoVuelto()
  If Trim(txtEfectivo.Text) = "" Then txtEfectivo.Text = "0.00"
  If Trim(txtEfectivoDolares.Text) = "" Then txtEfectivoDolares.Text = "0.00"
  If Trim(txtVueltoDolares.Text) = "" Then txtVueltoDolares.Text = "0.00"
  
  If Val(Replace(txtEfectivoDolares, ",", "")) <= Val(Replace(txtVueltoDolares, ",", "")) Then
     txtVueltoDolares.Text = "0.00"
  End If
  
  If ((Val(Replace(txtEfectivoDolares, ",", "")) - Val(Replace(txtVueltoDolares, ",", ""))) * nTipoCambio) >= Val(Replace(txtTotal, ",", "")) Then
     txtEfectivo.Text = "0.00"
  End If
    
  If Trim(txtEfectivo.Tag) = "0" Then
     txtEfectivo.Text = Format(Val(Replace(txtTotal, ",", "")) - _
                                Val(Replace(txtEfectivoDolares, ",", "")) * nTipoCambio + _
                                Val(Replace(txtVueltoDolares, ",", "")) * nTipoCambio + _
                                Val(Replace(txtVuelto, ",", "")), "###,###,###,##0.00")
  Else
    If Trim(txtEfectivoDolares.Tag) = "1" Or Trim(txtVueltoDolares.Tag) = "1" Then
    If ((Val(Replace(txtEfectivo, ",", "")) - Val(Replace(txtVuelto, ",", "")))) >= Val(Replace(txtTotal, ",", "")) Then
      If txtEfectivoDolares.Text = "0.00" Then txtVueltoDolares.Text = "0.00"
    End If
    End If
  End If
  txtVuelto.Text = (Val(Replace(txtEfectivo, ",", "")) + _
                   ((Val(Replace(txtEfectivoDolares, ",", "")) * nTipoCambio) - (Val(Replace(txtVueltoDolares, ",", "")) * nTipoCambio))) - _
                   Val(Replace(txtTotal, ",", ""))
  txtVuelto.Text = Format(txtVuelto.Text, "###,###,###,##0.00")
  
  txtEfectivo.Text = Format(txtEfectivo.Text, "###,###,###,##0.00")
  txtEfectivoDolares.Text = Format(txtEfectivoDolares.Text, "###,###,###,##0.00")
  txtVueltoDolares.Text = Format(txtVueltoDolares.Text, "###,###,###,##0.00")
        
If Trim(txtVueltoDolares.Tag) = "1" And Trim(txtEfectivo.Tag) = "0" Then
    If Val(Replace(txtVuelto.Text, ",", "")) < 0 Then
      txtEfectivo.Text = Format(-Val(Replace(txtVuelto.Text, ",", "")), "###,###,###,##0.00")
      txtVuelto.Text = "0.00"
    End If
End If
txtVueltoDolares.Tag = "0"
txtEfectivoDolares.Tag = "0"

End Sub
Private Sub EfectivoSolesCambia()

  If Trim(txtEfectivo.Text) = "" Then txtEfectivo.Text = "0.00"
  If Trim(txtEfectivoDolares.Text) = "" Then txtEfectivoDolares.Text = "0.00"
  If Trim(txtVueltoDolares.Text) = "" Then txtVueltoDolares.Text = "0.00"
  txtVueltoDolares.Text = Format(txtVueltoDolares.Text, "###,###,###,##0.00")
         
  txtVuelto = Format(Val(Replace(txtEfectivo, ",", "")) + _
                   Val(Replace(txtEfectivoDolares, ",", "")) * nTipoCambio - _
                   Val(Replace(txtVueltoDolares, ",", "")) * nTipoCambio - _
                   Val(Replace(txtTotal, ",", "")), "###,###,###,##0.00")
                                                                           
  
  txtVuelto.Text = Format(CStr(txtVuelto.Text), "###,###,###,##0.00")
  txtVueltoDolares.Text = Format(CStr(txtVueltoDolares.Text), "###,###,###,##0.00")
  txtEfectivo.Text = Format(CStr(txtEfectivo.Text), "###,###,###,##0.00")
  txtEfectivoDolares.Text = Format(CStr(txtEfectivoDolares.Text), "###,###,###,##0.00")
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

  On Error Resume Next

'SHIFT
'-----
'1, se está pulsando la tecla Shift (mayúsculas)
'2, se está pulsando Control
'4, se está pulsando Alt
'3, se están pulsando Shift y Ctrl,
'5, se están pulsando Shift y Alt,
'6, se están pulsando Ctrl y Alt,
'7, se están pulsando las tres teclas.


  Select Case Shift
  
    Case 2
        Select Case KeyCode
          Case 13
            Call cmdAceptar_Click
        End Select
    
  End Select
    
  Exit Sub
End Sub
