VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.2#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{F39CBE5C-2D1B-11D6-8D4A-0050043A2E60}#2.0#0"; "ProgBarProzent.ocx"
Object = "{9E070136-0FB6-11D3-A1BD-B0EC48C10000}#9.0#0"; "ACXPP.ocx"
Begin VB.Form FormFechas 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Selección de Meses"
   ClientHeight    =   7965
   ClientLeft      =   45
   ClientTop       =   1725
   ClientWidth     =   15045
   LinkTopic       =   "Form3"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   Moveable        =   0   'False
   ScaleHeight     =   7965
   ScaleWidth      =   15045
   Begin VB.Frame Frame_cursos 
      Caption         =   "Cartolas de curso"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   3015
      Left            =   8520
      TabIndex        =   25
      Top             =   120
      Width           =   5295
      Begin VB.ComboBox Combo_agno_cartola 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   240
         TabIndex        =   107
         Text            =   "Combo1"
         Top             =   1440
         Width           =   1335
      End
      Begin VB.CheckBox Chk_Rut 
         Caption         =   "Simple con Rut"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   104
         Top             =   2520
         Width           =   1575
      End
      Begin VB.Frame Frame5 
         Height          =   2175
         Left            =   3240
         TabIndex        =   90
         Top             =   720
         Width           =   1935
         Begin VB.OptionButton opt_destino_cartola 
            Caption         =   "Impresora"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   360
            TabIndex        =   94
            Top             =   720
            Width           =   1095
         End
         Begin VB.OptionButton opt_destino_cartola 
            Caption         =   "Pantalla"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   360
            TabIndex        =   93
            Top             =   360
            Width           =   1095
         End
         Begin VB.CommandButton btn_rep_cursos 
            Caption         =   "Generar Reporte"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   240
            TabIndex        =   92
            Top             =   1080
            Width           =   1455
         End
         Begin VB.CommandButton btn_can_cursos 
            Caption         =   "Cancelar"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   240
            TabIndex        =   91
            Top             =   1560
            Width           =   1455
         End
      End
      Begin VB.CheckBox chk_todos_cursos 
         Caption         =   "Todos los cursos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   30
         Top             =   2160
         Width           =   1575
      End
      Begin VB.ListBox lst_cursos 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1980
         Left            =   1800
         Style           =   1  'Checkbox
         TabIndex        =   29
         Top             =   720
         Width           =   1335
      End
      Begin VB.ComboBox cmb_modalidad 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1800
         TabIndex        =   26
         Top             =   360
         Width           =   3375
      End
      Begin VB.Label Label24 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   108
         Top             =   1200
         Width           =   735
      End
      Begin VB.Label Label4 
         Alignment       =   1  'Right Justify
         Caption         =   "Cursos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   840
         TabIndex        =   28
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Label3 
         Alignment       =   1  'Right Justify
         Caption         =   "Tipo de Enseñanza"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   120
         TabIndex        =   27
         Top             =   360
         Width           =   1575
      End
   End
   Begin VB.Frame frame_estad_mat 
      Caption         =   "Estadísticas de matrícula"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2535
      Left            =   8520
      TabIndex        =   76
      Top             =   3240
      Width           =   6375
      Begin VB.CommandButton masivo_limpiar 
         Caption         =   "Limpiar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   120
         TabIndex        =   113
         Top             =   1920
         Visible         =   0   'False
         Width           =   735
      End
      Begin VB.ComboBox Cmb_AgnoEstadMat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1680
         Style           =   2  'Dropdown List
         TabIndex        =   111
         Top             =   1560
         Width           =   1215
      End
      Begin VB.OptionButton opt_destino_emat 
         Caption         =   "Impresora"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   5160
         TabIndex        =   88
         Top             =   960
         Width           =   1095
      End
      Begin VB.OptionButton opt_destino_emat 
         Caption         =   "Pantalla"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   3960
         TabIndex        =   87
         Top             =   960
         Width           =   1095
      End
      Begin VB.ComboBox cmb_jor_emat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   960
         TabIndex        =   85
         Top             =   1080
         Width           =   1935
      End
      Begin VB.ComboBox cmb_mes_emat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   3960
         TabIndex        =   83
         Top             =   480
         Width           =   2295
      End
      Begin VB.CheckBox chk_todos_emat 
         Caption         =   "Todos los niveles"
         BeginProperty DataFormat 
            Type            =   4
            Format          =   "0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   13322
            SubFormatType   =   8
         EndProperty
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   1200
         TabIndex        =   81
         Top             =   2040
         Width           =   1575
      End
      Begin VB.ComboBox cmb_mod_emat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   120
         TabIndex        =   79
         Top             =   600
         Width           =   2775
      End
      Begin VB.CommandButton btn_rep_emat 
         Caption         =   "Generar Reporte"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4440
         TabIndex        =   78
         Top             =   1440
         Width           =   1455
      End
      Begin VB.CommandButton btn_can_emat 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4440
         TabIndex        =   77
         Top             =   1920
         Width           =   1455
      End
      Begin VB.ListBox lst_emat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1500
         Left            =   3000
         Style           =   1  'Checkbox
         TabIndex        =   82
         Top             =   600
         Width           =   735
      End
      Begin VB.Label Label26 
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   1200
         TabIndex        =   112
         Top             =   1560
         Width           =   495
      End
      Begin VB.Label Label21 
         Caption         =   "Niveles"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3000
         TabIndex        =   89
         Top             =   360
         Width           =   735
      End
      Begin VB.Label Label16 
         Caption         =   "Jornada"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   86
         Top             =   1080
         Width           =   735
      End
      Begin VB.Label Label19 
         Alignment       =   2  'Center
         Caption         =   "Mes de proceso"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3960
         TabIndex        =   84
         Top             =   240
         Width           =   2295
      End
      Begin VB.Label Label20 
         Caption         =   "Tipo de Enseñanza"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   80
         Top             =   360
         Width           =   1575
      End
      Begin VB.Line Line4 
         BorderColor     =   &H80000005&
         X1              =   3855
         X2              =   3855
         Y1              =   120
         Y2              =   2160
      End
      Begin VB.Line Line1 
         BorderColor     =   &H8000000C&
         X1              =   3840
         X2              =   3840
         Y1              =   120
         Y2              =   2520
      End
   End
   Begin VB.Frame Frame_Fechas 
      Caption         =   "Registro de cambios de curso"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2055
      Left            =   120
      TabIndex        =   24
      Top             =   5760
      Width           =   6375
      Begin VB.OptionButton opt_destino_registros 
         Caption         =   "Impresora"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   5040
         TabIndex        =   69
         Top             =   480
         Width           =   1215
      End
      Begin VB.OptionButton opt_destino_registros 
         Caption         =   "Pantalla"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   3720
         TabIndex        =   68
         Top             =   480
         Width           =   975
      End
      Begin VB.ComboBox Cmb_Mes_fin 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1560
         TabIndex        =   65
         Top             =   1440
         Width           =   1695
      End
      Begin VB.ComboBox Cmb_Mes_ini 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1560
         TabIndex        =   64
         Top             =   1080
         Width           =   1695
      End
      Begin VB.CommandButton Btn_Can_CambioCurso 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4200
         TabIndex        =   62
         Top             =   1320
         Width           =   1455
      End
      Begin VB.CommandButton Btn_gen_reportes 
         Caption         =   "Generar Reporte"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4200
         TabIndex        =   61
         Top             =   840
         Width           =   1455
      End
      Begin VB.ComboBox cmb_mod_cambiocurso 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   240
         TabIndex        =   60
         Top             =   720
         Width           =   3015
      End
      Begin VB.Line Line2 
         BorderColor     =   &H8000000C&
         X1              =   3480
         X2              =   3480
         Y1              =   120
         Y2              =   2040
      End
      Begin VB.Line Line3 
         BorderColor     =   &H80000005&
         X1              =   3495
         X2              =   3495
         Y1              =   120
         Y2              =   2040
      End
      Begin VB.Label Label2 
         Caption         =   "A"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   960
         TabIndex        =   67
         Top             =   1440
         Width           =   255
      End
      Begin VB.Label Label1 
         Caption         =   "DE"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   960
         TabIndex        =   66
         Top             =   1080
         Width           =   375
      End
      Begin VB.Label Label9 
         Caption         =   "Tipo de Enseñanza"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   63
         Top             =   480
         Width           =   1575
      End
   End
   Begin ACXPP.PP PP1 
      Left            =   14040
      Top             =   2160
      _ExtentX        =   847
      _ExtentY        =   847
      PageSize        =   3
      PageWidth       =   12240
      PageHeight      =   15840
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ScaleHeight     =   15810
      ScaleWidth      =   12210
   End
   Begin MSComDlg.CommonDialog Cmdialog 
      Left            =   10320
      Top             =   120
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Frame frame_reg_matriculas 
      Caption         =   "Seleccione Fecha"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2055
      Left            =   6720
      TabIndex        =   31
      Top             =   5760
      Width           =   6255
      Begin VB.ComboBox Combo_Agno_RegMat 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   240
         TabIndex        =   109
         Text            =   "Combo1"
         Top             =   1440
         Width           =   1215
      End
      Begin VB.OptionButton Opt_dest_reg 
         Caption         =   "Impresora"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   4920
         TabIndex        =   98
         Top             =   480
         Width           =   1095
      End
      Begin VB.OptionButton Opt_dest_reg 
         Caption         =   "Pantalla"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   3600
         TabIndex        =   97
         Top             =   480
         Width           =   1095
      End
      Begin VB.ComboBox cmb_mod_reg 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   240
         TabIndex        =   95
         Top             =   720
         Width           =   3015
      End
      Begin VB.CommandButton BTN_CAN_REGMATRI 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4080
         TabIndex        =   35
         Top             =   1320
         Width           =   1455
      End
      Begin VB.CommandButton btn_rep_regmatriculas 
         Caption         =   "Generar Reporte"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4080
         TabIndex        =   34
         Top             =   840
         Width           =   1455
      End
      Begin MSComCtl2.DTPicker dtp_reg_matriculas 
         Height          =   375
         Left            =   1680
         TabIndex        =   33
         Top             =   1440
         Width           =   1575
         _ExtentX        =   2778
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Format          =   51511297
         CurrentDate     =   37767
      End
      Begin VB.Label Label25 
         Caption         =   " Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   110
         Top             =   1200
         Width           =   855
      End
      Begin VB.Line Line6 
         BorderColor     =   &H80000005&
         X1              =   3375
         X2              =   3375
         Y1              =   240
         Y2              =   2055
      End
      Begin VB.Line Line5 
         BorderColor     =   &H8000000C&
         X1              =   3360
         X2              =   3360
         Y1              =   120
         Y2              =   2040
      End
      Begin VB.Label Label22 
         Caption         =   "Tipo de Enseñanza"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   96
         Top             =   480
         Width           =   1575
      End
      Begin VB.Label Label5 
         Alignment       =   1  'Right Justify
         Caption         =   "Término registro inicial"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   1680
         TabIndex        =   32
         Top             =   1200
         Width           =   1215
      End
   End
   Begin VB.Frame Frame_Vacantes 
      Caption         =   "Seleccione tipo de informe"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1575
      Left            =   120
      TabIndex        =   70
      Top             =   1680
      Width           =   4335
      Begin VB.CommandButton Btn_can_vacantes 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2640
         TabIndex        =   75
         Top             =   840
         Width           =   1455
      End
      Begin VB.CommandButton btn_acep_vacantes 
         Caption         =   "Aceptar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2640
         TabIndex        =   74
         Top             =   360
         Width           =   1455
      End
      Begin VB.OptionButton Opt_vacantes 
         Caption         =   "Vacantes Finales"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   2
         Left            =   240
         TabIndex        =   73
         Top             =   1080
         Width           =   2295
      End
      Begin VB.OptionButton Opt_vacantes 
         Caption         =   "Vacantes Reales"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   72
         Top             =   720
         Width           =   2295
      End
      Begin VB.OptionButton Opt_vacantes 
         Caption         =   "Vacantes Proyectadas"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   71
         Top             =   360
         Width           =   2295
      End
   End
   Begin VB.Frame Frame_fuentes 
      Caption         =   "Impresión de Informes de notas"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   5415
      Left            =   120
      TabIndex        =   36
      Top             =   120
      Width           =   8295
      Begin VB.TextBox txt_paginas 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   1320
         Locked          =   -1  'True
         TabIndex        =   23
         Top             =   4920
         Width           =   735
      End
      Begin VB.TextBox txt_cursoproceso 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   4080
         Locked          =   -1  'True
         TabIndex        =   51
         Top             =   4920
         Width           =   1095
      End
      Begin VB.CommandButton btn_can_notas 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   6840
         TabIndex        =   20
         Top             =   4920
         Width           =   1335
      End
      Begin VB.Frame Frame3 
         Height          =   1455
         Left            =   6480
         TabIndex        =   46
         Top             =   240
         Width           =   1695
         Begin VB.OptionButton opt_indiv_gral 
            Caption         =   "Individual"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   360
            TabIndex        =   3
            Top             =   480
            Width           =   1215
         End
         Begin VB.OptionButton opt_indiv_gral 
            Caption         =   "General"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   360
            TabIndex        =   4
            Top             =   840
            Width           =   1215
         End
      End
      Begin VB.CommandButton btn_impri_notas 
         Caption         =   "Generar Informes"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5280
         TabIndex        =   19
         Top             =   4920
         Width           =   1455
      End
      Begin ProgBarProzent.ProgBar Prgbar_Notas_total 
         Height          =   375
         Left            =   120
         TabIndex        =   22
         Top             =   4440
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   661
      End
      Begin MSComctlLib.ProgressBar Prgbar_Notas_curso 
         Height          =   375
         Left            =   120
         TabIndex        =   21
         Top             =   4080
         Width           =   5055
         _ExtentX        =   8916
         _ExtentY        =   661
         _Version        =   393216
         BorderStyle     =   1
         Appearance      =   1
      End
      Begin VB.Frame Frame4 
         Caption         =   "Salida"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1335
         Left            =   5280
         TabIndex        =   56
         Top             =   1680
         Width           =   2895
         Begin VB.ComboBox cmb_printers 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   120
            TabIndex        =   59
            Text            =   "cmb_printers"
            Top             =   720
            Width           =   2655
         End
         Begin VB.OptionButton Opt_destino 
            Caption         =   "Impresora"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   58
            Top             =   360
            Width           =   1215
         End
         Begin VB.OptionButton Opt_destino 
            Caption         =   "Pantalla"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   1680
            TabIndex        =   57
            Top             =   360
            Visible         =   0   'False
            Width           =   1095
         End
      End
      Begin VB.Frame Frame1 
         ForeColor       =   &H00FF0000&
         Height          =   1815
         Left            =   5280
         TabIndex        =   49
         Top             =   3000
         Width           =   2895
         Begin VB.OptionButton opt_tipopapel 
            Caption         =   "Oficio"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   1800
            TabIndex        =   55
            Top             =   900
            Width           =   975
         End
         Begin VB.OptionButton opt_tipopapel 
            Caption         =   "Carta"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   54
            Top             =   900
            Width           =   1335
         End
         Begin VB.ComboBox cmb_fuentes 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   120
            Sorted          =   -1  'True
            TabIndex        =   17
            Text            =   "cmb_fuentes"
            Top             =   480
            Width           =   2655
         End
         Begin VB.CheckBox chk_lineasverticales 
            Caption         =   "No dibujar líneas verticales para acelerar impresión"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   18
            Top             =   1320
            Width           =   2655
         End
         Begin VB.Label Label8 
            Caption         =   "Tipo de letra"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   50
            Top             =   240
            Width           =   1455
         End
      End
      Begin VB.Frame Frame_general 
         Height          =   2295
         Left            =   120
         TabIndex        =   37
         Top             =   1680
         Width           =   5055
         Begin VB.CheckBox chk_todos_notas 
            Caption         =   "Todos los cursos"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   15
            Top             =   1800
            Width           =   1575
         End
         Begin VB.ListBox lst_cursosinf 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   1500
            Left            =   3480
            Style           =   1  'Checkbox
            TabIndex        =   16
            Top             =   480
            Width           =   1335
         End
         Begin VB.ComboBox cmb_mod_notas 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   120
            TabIndex        =   14
            Top             =   600
            Width           =   3255
         End
         Begin VB.Label Label6 
            Caption         =   "Cursos"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   3480
            TabIndex        =   39
            Top             =   240
            Width           =   615
         End
         Begin VB.Label Label7 
            Caption         =   "Tipo de Enseñanza"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   38
            Top             =   360
            Width           =   1695
         End
      End
      Begin VB.Frame Frame_individual 
         Height          =   2295
         Left            =   120
         TabIndex        =   40
         Top             =   1680
         Width           =   5055
         Begin VB.ListBox lst_nom_alu 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   690
            Left            =   960
            TabIndex        =   6
            Top             =   600
            Width           =   3855
         End
         Begin VB.TextBox txt_mod_alu 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1440
            TabIndex        =   10
            Top             =   1080
            Width           =   3375
         End
         Begin VB.TextBox txt_letra_alu 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1200
            TabIndex        =   9
            Top             =   1080
            Width           =   255
         End
         Begin VB.TextBox txt_nom_alu 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   960
            TabIndex        =   5
            Top             =   360
            Width           =   3855
         End
         Begin VB.TextBox txt_estado_alu 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   960
            TabIndex        =   12
            Top             =   1800
            Width           =   2295
         End
         Begin VB.TextBox txt_apo_alu 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   960
            TabIndex        =   11
            Top             =   1440
            Width           =   3855
         End
         Begin VB.CommandButton btn_otro_alu 
            Caption         =   "Otro Alumno"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   3360
            TabIndex        =   13
            Top             =   1800
            Width           =   1455
         End
         Begin VB.TextBox txt_nivel_alu 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   960
            TabIndex        =   8
            Top             =   1080
            Width           =   255
         End
         Begin VB.TextBox txt_rut_alu 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   960
            TabIndex        =   7
            Top             =   720
            Width           =   1455
         End
         Begin VB.Label Label17 
            Caption         =   "Estado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   47
            Top             =   1800
            Width           =   855
         End
         Begin VB.Label Label15 
            Caption         =   "Apoderado"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   44
            Top             =   1440
            Width           =   855
         End
         Begin VB.Label Label14 
            Caption         =   "Curso"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   43
            Top             =   1080
            Width           =   495
         End
         Begin VB.Label Label13 
            Caption         =   "Rut"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   42
            Top             =   720
            Width           =   495
         End
         Begin VB.Label Label12 
            Caption         =   "Alumno"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   41
            Top             =   360
            Width           =   735
         End
      End
      Begin VB.Frame Frame2 
         Height          =   1455
         Left            =   120
         TabIndex        =   45
         Top             =   240
         Width           =   6255
         Begin VB.ComboBox cmb_agno 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   4560
            TabIndex        =   106
            Top             =   600
            Width           =   1455
         End
         Begin VB.OptionButton opt_final_parcial 
            Caption         =   "Informe Parcial de notas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   -240
            TabIndex        =   1
            Top             =   0
            Visible         =   0   'False
            Width           =   2055
         End
         Begin VB.OptionButton opt_final_parcial 
            Caption         =   "Informe Final de notas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   0
            Top             =   0
            Value           =   -1  'True
            Visible         =   0   'False
            Width           =   2055
         End
         Begin VB.ListBox lst_periodos 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   690
            Left            =   120
            TabIndex        =   2
            Top             =   480
            Width           =   4215
         End
         Begin VB.Label Label23 
            Caption         =   "Año a procesar"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   4680
            TabIndex        =   105
            Top             =   360
            Width           =   1335
         End
         Begin VB.Label Label10 
            Caption         =   "Seleccione período a procesar"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   48
            Top             =   240
            Width           =   2295
         End
      End
      Begin VB.Label Label18 
         Caption         =   "Nº de Páginas"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   53
         Top             =   4920
         Width           =   1095
      End
      Begin VB.Label Label11 
         Caption         =   "Curso activo"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   2880
         TabIndex        =   52
         Top             =   4920
         Width           =   975
      End
   End
   Begin VB.Frame Frame_Mat_Nuevos 
      Caption         =   "Seleccione Operación"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1455
      Left            =   120
      TabIndex        =   99
      Top             =   120
      Width           =   4935
      Begin VB.OptionButton Opt_mat_nuevos 
         Caption         =   "Tipos de pagos masivo"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   103
         Top             =   960
         Visible         =   0   'False
         Width           =   2175
      End
      Begin VB.OptionButton Opt_mat_nuevos 
         Caption         =   "Matricular alumnos nuevos sin curso"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   102
         Top             =   480
         Value           =   -1  'True
         Width           =   2895
      End
      Begin VB.CommandButton btn_ace_mat_nuevo 
         Caption         =   "Aceptar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3240
         TabIndex        =   101
         Top             =   360
         Width           =   1455
      End
      Begin VB.CommandButton btn_can_mat_nuevo 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3240
         TabIndex        =   100
         Top             =   840
         Width           =   1455
      End
   End
End
Attribute VB_Name = "FormFechas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim aperiodos() As String
Dim aasignaturas() As String
Dim aalumnos() As String
Dim Ngrado As String, rutalumno As String, RutApo As String, Sector As String, Codasi As String, Nombreasig As String
Dim letra As String
Dim modalidad As String, CodDes As String
Dim numperiodo As String, Nombreperiodo As String
Dim avancebarratotal As Integer
Dim PosImprInfFinal As Integer
Dim Min_max_gen, Promgral As String

Dim colegio As String 'polette

Dim contador As Integer
Dim veces As Integer
Dim nivel As String

Sub GeneraEstadMat()

    Dim Ngrado As String, LetCur As String
    Dim Col1 As String, Col2 As Integer, Col3 As Integer, Col4 As Integer, Col5 As Integer, Col6 As Integer
    Dim Col7 As Integer, Col8 As Integer, Col9 As Integer, Col10 As Integer, Col11 As Integer, Col12 As Integer
    Dim Col13 As Integer, Col14 As Integer, Col15 As Integer, Col16 As Integer, Col17 As Integer, Col18 As Integer, Col19 As Integer, Col20 As Integer
    Dim jornada As String
    Dim SCol2 As Integer, SCol3 As Integer, SCol4 As Integer, SCol5 As Integer, SCol6 As Integer
    Dim SCol7 As Integer, SCol8 As Integer, SCol9 As Integer, SCol10 As Integer, SCol11 As Integer, SCol12 As Integer
    Dim SCol13 As Integer, SCol14 As Integer, SCol15 As Integer, SCol16 As Integer, SCol17 As Integer, SCol18 As Integer, SCol19 As Integer, SCol20 As Integer
    Dim Niveles As String
    Dim TCol2 As Integer, TCol3 As Integer, TCol4 As Integer, TCol5 As Integer, TCol6 As Integer
    Dim TCol7 As Integer, TCol8 As Integer, TCol9 As Integer, TCol10 As Integer, TCol11 As Integer, TCol12 As Integer
    Dim TCol13 As Integer, TCol14 As Integer, TCol15 As Integer, TCol16 As Integer, TCol17 As Integer, TCol18 As Integer, TCol19 As Integer, TCol20 As Integer
    Dim Haycursos As Boolean
    
    Dim FecMatINI As String

If Me.cmb_mod_emat.Text = "Todas" Then
        MsgBox "Ha seleccionado todos los niveles"
   For veces = 1 To 4
   Set Rendim = DBEngine.Workspaces(0).OpenDatabase(DirAplicacion & "\GesTemp.mdb")
        
    'Calculo la cantidad de cursos del nivel
    If Me.cmb_jor_emat <> "Todas" Then
        jornada = " and cod_jor = '" & DevuelveCampo("jornadas", "", "cod_jor", "des_jor ='" & Me.cmb_jor_emat.Text & "'", conn) & "'"
    Else
        jornada = ""
    End If
    
    'Inicializo barra de progreso.....
    Form_Progress.Label1.Caption = "Generando Estadísticas..."
    Form_Progress.Show
    Abarra = Me.lst_emat.SelCount
    Form_Progress.ProgBar1.MaxValue = Abarra
    Abarra = 0
    
    ' Captura de días de inicio y fin del mes anterior
    a = Me.cmb_mes_emat.ListIndex
    b = ameses(a, 1): c = ameses(a, 2): d = ameses(a, 3)
    b2 = ameses(a + 1, 1): C2 = ameses(a + 1, 2): d2 = ameses(a + 1, 3)
    If Me.cmb_mes_emat.ListIndex > 0 Then
        FechainiAnt = InvierteFecha(Anno & "/" & ameses(Me.cmb_mes_emat.ListIndex, 2), "R")
        FechaFinAnt = InvierteFecha(Anno & "/" & ameses(Me.cmb_mes_emat.ListIndex, 3), "R")
    Else
        FechainiAnt = ""
        FechaFinAnt = ""
    End If
    
    'Captura de días de inicio y fin del mes actual
    Fechainiact = Left(ameses(Me.cmb_mes_emat.ListIndex + 1, 2), 2)
    FechaFinAct = Left(ameses(Me.cmb_mes_emat.ListIndex + 1, 3), 2)
    
    ' Recorro la lista
    Niveles = ""
    TCol2 = 0: TCol3 = 0: TCol4 = 0: TCol5 = 0: TCol6 = 0: TCol7 = 0: TCol8 = 0: TCol9 = 0
    TCol10 = 0: TCol11 = 0: TCol12 = 0: TCol13 = 0: TCol14 = 0: TCol15 = 0: TCol16 = 0
    TCol17 = 0: TCol18 = 0: TCol19 = 0: TCol20 = 0
    For t = 0 To Me.lst_emat.ListCount - 1
    
        'Inicializo variables de subtotales
        SCol2 = 0: SCol3 = 0: SCol4 = 0: SCol5 = 0: SCol6 = 0: SCol7 = 0: SCol8 = 0: SCol9 = 0
        SCol10 = 0: SCol11 = 0: SCol12 = 0: SCol13 = 0: SCol14 = 0: SCol15 = 0: SCol16 = 0
        SCol17 = 0: SCol18 = 0: SCol19 = 0: SCol20 = 0
        
        'Preguntando por los niveles seleccionados
        If Me.lst_emat.Selected(t) = True Then
            'Cada vez que encuentro una selección, busco los cursos correspondientes.....
            Niveles = Niveles & t + 1 & "-"
            
            Col1 = "": Col2 = 0: Col3 = 0: Col4 = 0: Col5 = 0: Col6 = 0: Col7 = 0: Col8 = 0: Col9 = 0
            Col10 = 0: Col11 = 0: Col12 = 0: Col13 = 0: Col14 = 0: Col15 = 0: Col16 = 0: Col17 = 0: Col18 = 0: Col19 = 0: Col20 = 0
            rs.CursorLocation = adUseClient
            rs.Open "select num_gra, let_cur from cursos where num_gra = '" & val(t) + 1 & "' and cod_ens ='" & modalidad & "'" & jornada & " and agno='" & Trim(Cmb_AgnoEstadMat.Text) & "' order by num_gra, let_cur", conn
            If rs.RecordCount > 0 Then
                Haycursos = True
                While Not rs.EOF
                    
                    Ngrado = rs("num_gra"): LetCur = rs("let_cur")
                    If UCase(CodDes) = "K" Or UCase(CodDes) = "PK" Then
                        Col1 = UCase(CodDes) & " " & LetCur
                    Else
                        Col1 = Ngrado & "º" & LetCur
                    End If
                    
'                    If UCase(CodDes) = "996" Then
'                        Col1 = "PK " & LetCur
'                    End If
'
'                    If UCase(CodDes) = "010" Then
'                        Col1 = "K " & LetCur
'                    End If
'
'                    If UCase(CodDes) = "110" Then
'                        Col1 = Ngrado & "º" & LetCur & " Basico"
'                    End If
'
'                    If UCase(CodDes) = "310" Then
'                        Col1 = Ngrado & "º" & LetCur & " Media"
'                    End If
                    
                    
                    
                        
                    ' Si existe mes anterior genero estadisticas
                    '*************************************************************'
                    'Dim FecMatINI As String
                    FecMatINI = RetornaCampo("CFG", "valor", "Param='PerEscIni' and agno=" & Trim(Cmb_AgnoEstadMat.Text), conn)
                    'Matricula mes anterior Hombres
                    RsAux.CursorLocation = adUseClient
                    a = "select count(m.ci_alu) from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and (month(a.fec_ing_curso) < '" & Fechainiact & "' or a.fec_ing_curso='" & FecMatINI & "') and (month(m.fec_retiro) >= '" & Fechainiact & "' or m.fec_retiro = '1111-11-11') and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and (month(a.fec_cam) >= '" & Fechainiact & "' or a.fec_cam = '1111-11-11') and m.fec_mat= a.fec_mat and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    Col2 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Matricula mes anterior Mujeres
                    RsAux.Open "select count(m.ci_alu) from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and (month(a.fec_ing_curso) < '" & Fechainiact & "' or a.fec_ing_curso='" & FecMatINI & "') and (month(m.fec_retiro) >= '" & Fechainiact & "' or m.fec_retiro = '1111-11-11')and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and (month(a.fec_cam) >= '" & Fechainiact & "' or a.fec_cam = '1111-11-11') and m.fec_mat= a.fec_mat AND m.anno_mat=a.agno AND m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'", conn
                    Col3 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Total Matrícula mes anterior
                    Col4 = Col2 + Col3
                    
                    'Altas del mes actual Hombres
                    a = "SELECT count(t.a) as suma FROM " _
                      & "(select m.ci_alu as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_alta)= '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and a.fec_alta=a.fec_ing_curso and a.fec_alta>'" & FecMatINI & "' and m.fec_mat=a.fec_mat and m.anno_mat=a.agno AND m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" _
                      & " union " _
                      & "select a.ci_alu as a from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra_new='" & Ngrado & "' and a.let_cur_new ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "') as t"
                    'a = "select count(m.ci_alu) as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_alta)= '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and a.fec_alta=a.fec_ing_curso and a.fec_alta>'" & FecMatINI & "' and m.fec_mat=a.fec_mat and m.anno_mat=a.agno AND m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    'Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.cod_ens}= '" & CodEns & "' and {matriculas.FEC_MAT}  >= date( " & fechainicio & ") and {matriculas.FEC_MAT} <= date( " & fechafin & ")")
                    Col5 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Altas del mes actual Mujeres
                    a = "SELECT count(t.a) as suma FROM " _
                      & "(select m.ci_alu as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_alta)= '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and a.fec_alta=a.fec_ing_curso and a.fec_alta>'" & FecMatINI & "' and m.fec_mat=a.fec_mat and m.anno_mat=a.agno AND m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" _
                      & " union " _
                      & "select a.ci_alu as a from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra_new='" & Ngrado & "' and a.let_cur_new ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "') as t"
                    'a = "select count(m.ci_alu) as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_alta)= '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and a.fec_alta=a.fec_ing_curso and a.fec_alta>'" & FecMatINI & "' and m.fec_mat=a.fec_mat and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    Col6 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    Col7 = Col5 + Col6
                    
                    'Bajas del mes actual Hombres
                    a = "select count(m.ci_alu) from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" ' and ucase(m.activo_alu)='NO' and a.activo_alu=m.activo_alu"
                      a = "SELECT count(t.a) as suma FROM " _
                      & "(select m.ci_alu as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" _
                      & " union " _
                      & "select a.ci_alu as a from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "') as t"
                  '  a = "select count(m.ci_alu) as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    Col8 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Bajas del mes actual Mujeres
                    a = "SELECT count(t.a) as suma FROM " _
                      & "(select m.ci_alu as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" _
                      & " union " _
                      & "select a.ci_alu as a from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "') as t"
                    'a = "select count(m.ci_alu) as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    Col9 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Total Bajas del mes actual
                    Col10 = Col8 + Col9
                                        
                    'Cambios de curso
                    'Hombres que se cambian al curso
                    RsAux.Open "select count(a.ci_alu) from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra_new='" & Ngrado & "' and a.let_cur_new ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "'", conn
                    RsAux.Close

                    'Hombres que salen del curso
                    RsAux.Open "select count(a.ci_alu) from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "'", conn
                    RsAux.Close
                    
                    'Cambios de curso Hombres
                    
                    'Mujeres que se cambian al curso
                    a = "select count(a.ci_alu) from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra_new='" & Ngrado & "' and a.let_cur_new ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    RsAux.Close
                    
                    'Mujeres que salen del curso
                    RsAux.Open "select count(a.ci_alu) from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "'", conn
                    RsAux.Close
                    
                    'Cambios de curso Mujeres
                    
                    'Totales del Mes
                    Col18 = (Col2 - Col8) + Col5 + Col13
                    Col19 = (Col3 - Col9) + Col6 + Col16
                    Col20 = Col18 + Col19
                    'Escribo en la tabla los valores generados
                    Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values('" & Col1 & "' , '" & str(Col2) & "' , '" & str(Col3) & "' , '" & str(Col4) & "' , '" & str(Col5) & "' , '" & str(Col6) & "' , '" & str(Col7) & "' , '" & str(Col8) & "' , '" & str(Col9) & "' , '" & str(Col10) & "' , '" & str(Col11) & "' , '" & str(Col12) & "' , '" & str(Col13) & "' , '" & str(Col14) & "' , '" & str(Col15) & "' , '" & str(Col16) & "' , '" & str(Col17) & "' , '" & str(Col18) & "' , '" & str(Col19) & "', '" & str(Col20) & "')"
                    'Acumulo SubTotales
                    SCol2 = SCol2 + Col2: SCol3 = SCol3 + Col3: SCol4 = SCol4 + Col4
                    SCol5 = SCol5 + Col5: SCol6 = SCol6 + Col6: SCol7 = SCol7 + Col7
                    SCol8 = SCol8 + Col8: SCol9 = SCol9 + Col9: SCol10 = SCol10 + Col10
                    SCol11 = SCol11 + Col11: SCol12 = SCol12 + Col12: SCol13 = SCol13 + Col13
                    SCol14 = SCol14 + Col14: SCol15 = SCol15 + Col15: SCol16 = SCol16 + Col16
                    SCol17 = SCol17 + Col17: SCol18 = SCol18 + Col18: SCol19 = SCol19 + Col19
                    SCol20 = SCol20 + Col20
                    'Acumulo Totales
                    
                    rs.MoveNext
                               
                Wend
                TCol2 = TCol2 + SCol2: TCol3 = TCol3 + SCol3: TCol4 = TCol4 + SCol4
                TCol5 = TCol5 + SCol5: TCol6 = TCol6 + SCol6: TCol7 = TCol7 + SCol7
                TCol8 = TCol8 + SCol8: TCol9 = TCol9 + SCol9: TCol10 = TCol10 + SCol10
                TCol11 = TCol11 + SCol11: TCol12 = TCol12 + SCol12: TCol13 = TCol13 + SCol13
                TCol14 = TCol14 + SCol14: TCol15 = TCol15 + SCol15: TCol16 = TCol16 + SCol16
                TCol17 = TCol17 + SCol17: TCol18 = TCol18 + SCol18: TCol19 = TCol19 + SCol19
                TCol20 = TCol20 + SCol20
            Else
                Haycursos = False
            End If
            rs.Close
            
            'en blanco y subtotal
            If Haycursos Then
                Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values(Null , Null  , Null  , Null  , Null , Null , Null , Null , Null  , Null  , Null  , Null  , Null , Null  , Null  , Null, Null , Null  , Null  , Null)"
                Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values('Subtotales :' , '" & str(SCol2) & "' , '" & str(SCol3) & "' , '" & str(SCol4) & "' , '" & str(SCol5) & "' , '" & str(SCol6) & "' , '" & str(SCol7) & "' , '" & str(SCol8) & "' , '" & str(SCol9) & "' , '" & str(SCol10) & "' , '" & str(SCol11) & "' , '" & str(SCol12) & "' , '" & str(SCol13) & "', '" & str(SCol14) & "' , '" & str(SCol15) & "' , '" & str(SCol16) & "' , '" & str(SCol17) & "' , '" & str(SCol18) & "' , '" & str(SCol19) & "' , '" & str(SCol20) & "')"
                Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values(Null , Null  , Null  , Null  , Null , Null , Null , Null , Null  , Null  , Null  , Null  , Null , Null  , Null  , Null , Null , Null  , Null  , Null)"
                Haycursos = False
            End If
            
        End If
        Abarra = Abarra + 1
        Form_Progress.ProgBar1.ShowProgress Abarra
        Form_Progress.SetFocus
        DoEvents
    Next t
    Niveles = Mid(Niveles, 1, Len(Niveles) - 1)
    Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values('TOTALES :' , '" & str(TCol2) & "' , '" & str(TCol3) & "' , '" & str(TCol4) & "' , '" & str(TCol5) & "' , '" & str(TCol6) & "' , '" & str(TCol7) & "' , '" & str(TCol8) & "' , '" & str(TCol9) & "' , '" & str(TCol10) & "' , '" & str(TCol11) & "' , '" & str(TCol12) & "' , '" & str(TCol13) & "', '" & str(TCol14) & "' , '" & str(TCol15) & "' , '" & str(TCol16) & "', '" & str(TCol17) & "', '" & str(TCol18) & "', '" & str(TCol19) & "', '" & str(TCol20) & "')"
    Rendim.Close
    Form_Progress.ProgBar1.ShowProgress 0
    Unload Form_Progress
    titulo = "ESTADISTICAS DE MATRÍCULA MES DE " & UCase(Me.cmb_mes_emat) & " AÑO " & Trim(Cmb_AgnoEstadMat.Text)
    Nombrecol = DevuelveCampo("establecimientos", "", "nom_est", "nom_est <> ''", conn)
    Direccol = DevuelveCampo("establecimientos", "", "dir_est", "dir_est <> ''", conn)
    ComunaCol = DevuelveCampo("establecimientos", "", "localidad_est", "localidad_est <> ''", conn)
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.Formulas(0) = "nomcol = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "dircol = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacol = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "titulo= '" & titulo & "'"
    Form_main.CrystalReport.Formulas(4) = "hora = '" & Time & "'"
    Form_main.CrystalReport.Formulas(5) = "Tipens = '" & Me.cmb_mod_emat.Text & "'"
    Form_main.CrystalReport.Formulas(6) = "Niveles = '" & Niveles & "'"
    Form_main.CrystalReport.Formulas(7) = "Jornada = '" & Me.cmb_jor_emat & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\Est_matricula.rpt"
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\GesTemp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    
    ''Pruebas
'    Kill (DirAplicacion & "\GesTemp.mdb")
'    btn_rep_emat_Click
    
        Call cmb_mod_emat_Click
        'Call btn_rep_emat_Click
   Next veces

    Else
    Set Rendim = DBEngine.Workspaces(0).OpenDatabase(DirAplicacion & "\GesTemp.mdb")

    'Calculo la cantidad de cursos del nivel
    If Me.cmb_jor_emat <> "Todas" Then
        jornada = " and cod_jor = '" & DevuelveCampo("jornadas", "", "cod_jor", "des_jor ='" & Me.cmb_jor_emat.Text & "'", conn) & "'"
    Else
        jornada = ""
    End If
    
    'Inicializo barra de progreso.....
    Form_Progress.Label1.Caption = "Generando Estadísticas..."
    Form_Progress.Show
    Abarra = Me.lst_emat.SelCount
    Form_Progress.ProgBar1.MaxValue = Abarra
    Abarra = 0
    
    ' Captura de días de inicio y fin del mes anterior
    a = Me.cmb_mes_emat.ListIndex
    b = ameses(a, 1): c = ameses(a, 2): d = ameses(a, 3)
    b2 = ameses(a + 1, 1): C2 = ameses(a + 1, 2): d2 = ameses(a + 1, 3)
    If Me.cmb_mes_emat.ListIndex > 0 Then
        FechainiAnt = InvierteFecha(Anno & "/" & ameses(Me.cmb_mes_emat.ListIndex, 2), "R")
        FechaFinAnt = InvierteFecha(Anno & "/" & ameses(Me.cmb_mes_emat.ListIndex, 3), "R")
    Else
        FechainiAnt = ""
        FechaFinAnt = ""
    End If
    
    'Captura de días de inicio y fin del mes actual
    Fechainiact = Left(ameses(Me.cmb_mes_emat.ListIndex + 1, 2), 2)
    FechaFinAct = Left(ameses(Me.cmb_mes_emat.ListIndex + 1, 3), 2)
    
    ' Recorro la lista
    Niveles = ""
    TCol2 = 0: TCol3 = 0: TCol4 = 0: TCol5 = 0: TCol6 = 0: TCol7 = 0: TCol8 = 0: TCol9 = 0
    TCol10 = 0: TCol11 = 0: TCol12 = 0: TCol13 = 0: TCol14 = 0: TCol15 = 0: TCol16 = 0
    TCol17 = 0: TCol18 = 0: TCol19 = 0: TCol20 = 0
    For t = 0 To Me.lst_emat.ListCount - 1
    
        'Inicializo variables de subtotales
        SCol2 = 0: SCol3 = 0: SCol4 = 0: SCol5 = 0: SCol6 = 0: SCol7 = 0: SCol8 = 0: SCol9 = 0
        SCol10 = 0: SCol11 = 0: SCol12 = 0: SCol13 = 0: SCol14 = 0: SCol15 = 0: SCol16 = 0
        SCol17 = 0: SCol18 = 0: SCol19 = 0: SCol20 = 0
        
        'Preguntando por los niveles seleccionados
        If Me.lst_emat.Selected(t) = True Then
            'Cada vez que encuentro una selección, busco los cursos correspondientes.....
            Niveles = Niveles & t + 1 & "-"
            
            Col1 = "": Col2 = 0: Col3 = 0: Col4 = 0: Col5 = 0: Col6 = 0: Col7 = 0: Col8 = 0: Col9 = 0
            Col10 = 0: Col11 = 0: Col12 = 0: Col13 = 0: Col14 = 0: Col15 = 0: Col16 = 0: Col17 = 0: Col18 = 0: Col19 = 0: Col20 = 0
            rs.CursorLocation = adUseClient
            rs.Open "select num_gra, let_cur from cursos where num_gra = '" & val(t) + 1 & "' and cod_ens ='" & modalidad & "'" & jornada & " and agno='" & Trim(Cmb_AgnoEstadMat.Text) & "' order by num_gra, let_cur", conn
            If rs.RecordCount > 0 Then
                Haycursos = True
                While Not rs.EOF
                    
                    Ngrado = rs("num_gra"): LetCur = rs("let_cur")
                    If UCase(CodDes) = "K" Or UCase(CodDes) = "PK" Then
                        Col1 = UCase(CodDes) & " " & LetCur
                    Else
                        Col1 = Ngrado & "º" & LetCur
                    End If
                        
                    ' Si existe mes anterior genero estadisticas
                    '*************************************************************'
                    'Dim FecMatINI As String
                    FecMatINI = RetornaCampo("CFG", "valor", "Param='PerEscIni' and agno=" & Trim(Cmb_AgnoEstadMat.Text), conn)
                    'Matricula mes anterior Hombres
                    RsAux.CursorLocation = adUseClient
                    a = "select count(m.ci_alu) from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and (month(a.fec_ing_curso) < '" & Fechainiact & "' or a.fec_ing_curso='" & FecMatINI & "') and (month(m.fec_retiro) >= '" & Fechainiact & "' or m.fec_retiro = '1111-11-11') and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and (month(a.fec_cam) >= '" & Fechainiact & "' or a.fec_cam = '1111-11-11') and m.fec_mat= a.fec_mat and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    Col2 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Matricula mes anterior Mujeres
                    RsAux.Open "select count(m.ci_alu) from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and (month(a.fec_ing_curso) < '" & Fechainiact & "' or a.fec_ing_curso='" & FecMatINI & "') and (month(m.fec_retiro) >= '" & Fechainiact & "' or m.fec_retiro = '1111-11-11')and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and (month(a.fec_cam) >= '" & Fechainiact & "' or a.fec_cam = '1111-11-11') and m.fec_mat= a.fec_mat AND m.anno_mat=a.agno AND m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'", conn
                    Col3 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Total Matrícula mes anterior
                    Col4 = Col2 + Col3
                    
                    'Altas del mes actual Hombres
                    a = "SELECT count(t.a) as suma FROM " _
                      & "(select m.ci_alu as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_alta)= '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and a.fec_alta=a.fec_ing_curso and a.fec_alta>'" & FecMatINI & "' and m.fec_mat=a.fec_mat and m.anno_mat=a.agno AND m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" _
                      & " union " _
                      & "select a.ci_alu as a from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra_new='" & Ngrado & "' and a.let_cur_new ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "') as t"
                    'a = "select count(m.ci_alu) as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_alta)= '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and a.fec_alta=a.fec_ing_curso and a.fec_alta>'" & FecMatINI & "' and m.fec_mat=a.fec_mat and m.anno_mat=a.agno AND m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    'Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.cod_ens}= '" & CodEns & "' and {matriculas.FEC_MAT}  >= date( " & fechainicio & ") and {matriculas.FEC_MAT} <= date( " & fechafin & ")")
                    Col5 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Altas del mes actual Mujeres
                    a = "SELECT count(t.a) as suma FROM " _
                      & "(select m.ci_alu as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_alta)= '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and a.fec_alta=a.fec_ing_curso and a.fec_alta>'" & FecMatINI & "' and m.fec_mat=a.fec_mat and m.anno_mat=a.agno AND m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" _
                      & " union " _
                      & "select a.ci_alu as a from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra_new='" & Ngrado & "' and a.let_cur_new ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "') as t"
                    'a = "select count(m.ci_alu) as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_alta)= '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and a.fec_alta=a.fec_ing_curso and a.fec_alta>'" & FecMatINI & "' and m.fec_mat=a.fec_mat and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    Col6 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    Col7 = Col5 + Col6
                    
                    'Bajas del mes actual Hombres
                    a = "select count(m.ci_alu) from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" ' and ucase(m.activo_alu)='NO' and a.activo_alu=m.activo_alu"
                      a = "SELECT count(t.a) as suma FROM " _
                      & "(select m.ci_alu as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" _
                      & " union " _
                      & "select a.ci_alu as a from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "') as t"
                  '  a = "select count(m.ci_alu) as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='1' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    Col8 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Bajas del mes actual Mujeres
                    a = "SELECT count(t.a) as suma FROM " _
                      & "(select m.ci_alu as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'" _
                      & " union " _
                      & "select a.ci_alu as a from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "') as t"
                    'a = "select count(m.ci_alu) as a from alu_x_cur a, matriculas m, postulantes p where p.ci_alu=m.ci_alu and m.ci_alu=a.ci_alu and p.sex_alu='2' and month(m.fec_retiro) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur='" & LetCur & "' and m.fec_mat=a.fec_mat and m.fec_retiro<>'1111-11-11' and a.fec_cam='1111-11-11' and m.anno_mat=a.agno and m.anno_mat='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    Col9 = IIf(RsAux(0) > 0, RsAux(0), 0): RsAux.Close
                    'Total Bajas del mes actual
                    Col10 = Col8 + Col9
                                        
                    'Cambios de curso
                    'Hombres que se cambian al curso
                    RsAux.Open "select count(a.ci_alu) from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra_new='" & Ngrado & "' and a.let_cur_new ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "'", conn
                    RsAux.Close

                    'Hombres que salen del curso
                    RsAux.Open "select count(a.ci_alu) from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='1' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "'", conn
                    RsAux.Close
                    
                    'Cambios de curso Hombres
                    
                    'Mujeres que se cambian al curso
                    a = "select count(a.ci_alu) from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra_new='" & Ngrado & "' and a.let_cur_new ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "'"
                    RsAux.Open a, conn
                    RsAux.Close
                    
                    'Mujeres que salen del curso
                    RsAux.Open "select count(a.ci_alu) from alu_x_cur a, postulantes p where p.ci_alu=a.ci_alu and p.sex_alu='2' and month(a.fec_cam) = '" & Fechainiact & "' and a.cod_ens ='" & modalidad & "' and a.num_gra='" & Ngrado & "' and a.let_cur ='" & LetCur & "' and a.fec_cam<>'1111-11-11' and a.agno='" & Trim(Cmb_AgnoEstadMat.Text) & "'", conn
                    RsAux.Close
                    
                    'Cambios de curso Mujeres
                    
                    'Totales del Mes
                    Col18 = (Col2 - Col8) + Col5 + Col13
                    Col19 = (Col3 - Col9) + Col6 + Col16
                    Col20 = Col18 + Col19
                    'Escribo en la tabla los valores generados
                    Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values('" & Col1 & "' , '" & str(Col2) & "' , '" & str(Col3) & "' , '" & str(Col4) & "' , '" & str(Col5) & "' , '" & str(Col6) & "' , '" & str(Col7) & "' , '" & str(Col8) & "' , '" & str(Col9) & "' , '" & str(Col10) & "' , '" & str(Col11) & "' , '" & str(Col12) & "' , '" & str(Col13) & "' , '" & str(Col14) & "' , '" & str(Col15) & "' , '" & str(Col16) & "' , '" & str(Col17) & "' , '" & str(Col18) & "' , '" & str(Col19) & "', '" & str(Col20) & "')"
                    'Acumulo SubTotales
                    SCol2 = SCol2 + Col2: SCol3 = SCol3 + Col3: SCol4 = SCol4 + Col4
                    SCol5 = SCol5 + Col5: SCol6 = SCol6 + Col6: SCol7 = SCol7 + Col7
                    SCol8 = SCol8 + Col8: SCol9 = SCol9 + Col9: SCol10 = SCol10 + Col10
                    SCol11 = SCol11 + Col11: SCol12 = SCol12 + Col12: SCol13 = SCol13 + Col13
                    SCol14 = SCol14 + Col14: SCol15 = SCol15 + Col15: SCol16 = SCol16 + Col16
                    SCol17 = SCol17 + Col17: SCol18 = SCol18 + Col18: SCol19 = SCol19 + Col19
                    SCol20 = SCol20 + Col20
                    'Acumulo Totales
                    
                    rs.MoveNext
                               
                Wend
                TCol2 = TCol2 + SCol2: TCol3 = TCol3 + SCol3: TCol4 = TCol4 + SCol4
                TCol5 = TCol5 + SCol5: TCol6 = TCol6 + SCol6: TCol7 = TCol7 + SCol7
                TCol8 = TCol8 + SCol8: TCol9 = TCol9 + SCol9: TCol10 = TCol10 + SCol10
                TCol11 = TCol11 + SCol11: TCol12 = TCol12 + SCol12: TCol13 = TCol13 + SCol13
                TCol14 = TCol14 + SCol14: TCol15 = TCol15 + SCol15: TCol16 = TCol16 + SCol16
                TCol17 = TCol17 + SCol17: TCol18 = TCol18 + SCol18: TCol19 = TCol19 + SCol19
                TCol20 = TCol20 + SCol20
            Else
                Haycursos = False
            End If
            rs.Close
            
            'en blanco y subtotal
            If Haycursos Then
                Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values(Null , Null  , Null  , Null  , Null , Null , Null , Null , Null  , Null  , Null  , Null  , Null , Null  , Null  , Null, Null , Null  , Null  , Null)"
                Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values('Subtotales :' , '" & str(SCol2) & "' , '" & str(SCol3) & "' , '" & str(SCol4) & "' , '" & str(SCol5) & "' , '" & str(SCol6) & "' , '" & str(SCol7) & "' , '" & str(SCol8) & "' , '" & str(SCol9) & "' , '" & str(SCol10) & "' , '" & str(SCol11) & "' , '" & str(SCol12) & "' , '" & str(SCol13) & "', '" & str(SCol14) & "' , '" & str(SCol15) & "' , '" & str(SCol16) & "' , '" & str(SCol17) & "' , '" & str(SCol18) & "' , '" & str(SCol19) & "' , '" & str(SCol20) & "')"
                Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values(Null , Null  , Null  , Null  , Null , Null , Null , Null , Null  , Null  , Null  , Null  , Null , Null  , Null  , Null , Null , Null  , Null  , Null)"
                Haycursos = False
            End If
            
        End If
        Abarra = Abarra + 1
        Form_Progress.ProgBar1.ShowProgress Abarra
        Form_Progress.SetFocus
        DoEvents
    Next t
    Niveles = Mid(Niveles, 1, Len(Niveles) - 1)
    Rendim.Execute "INSERT INTO Detalles (C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) values('TOTALES :' , '" & str(TCol2) & "' , '" & str(TCol3) & "' , '" & str(TCol4) & "' , '" & str(TCol5) & "' , '" & str(TCol6) & "' , '" & str(TCol7) & "' , '" & str(TCol8) & "' , '" & str(TCol9) & "' , '" & str(TCol10) & "' , '" & str(TCol11) & "' , '" & str(TCol12) & "' , '" & str(TCol13) & "', '" & str(TCol14) & "' , '" & str(TCol15) & "' , '" & str(TCol16) & "', '" & str(TCol17) & "', '" & str(TCol18) & "', '" & str(TCol19) & "', '" & str(TCol20) & "')"
    Rendim.Close
    Form_Progress.ProgBar1.ShowProgress 0
    Unload Form_Progress
    titulo = "ESTADISTICAS DE MATRÍCULA MES DE " & UCase(Me.cmb_mes_emat) & " AÑO " & Trim(Cmb_AgnoEstadMat.Text)
    Nombrecol = DevuelveCampo("establecimientos", "", "nom_est", "nom_est <> ''", conn)
    Direccol = DevuelveCampo("establecimientos", "", "dir_est", "dir_est <> ''", conn)
    ComunaCol = DevuelveCampo("establecimientos", "", "localidad_est", "localidad_est <> ''", conn)
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.Formulas(0) = "nomcol = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "dircol = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacol = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "titulo= '" & titulo & "'"
    Form_main.CrystalReport.Formulas(4) = "hora = '" & Time & "'"
    Form_main.CrystalReport.Formulas(5) = "Tipens = '" & Me.cmb_mod_emat.Text & "'"
    Form_main.CrystalReport.Formulas(6) = "Niveles = '" & Niveles & "'"
    Form_main.CrystalReport.Formulas(7) = "Jornada = '" & Me.cmb_jor_emat & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\Est_matricula.rpt"
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\GesTemp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    'kill (DirAplicacion & "\GesTemp.mdb")
    
End If
End Sub


Function Imprimenotasalumno(rutalumno As String, Ngrado As String, letra As String, CodModalidad As String, NombreModalidad As String, numperiodo As String) As Integer
'    Dim Promproceso As Single, Promponderado As Single, Promsemestre As Single, valnota As Single   'notasincoma As Single, nota As Single,
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    Printer.FontSize = 8
    Printer.CurrentX = 1600: Printer.CurrentY = 1400: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1600: Printer.CurrentY = 1600: Printer.Print (Ngrado & " " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1600: Printer.CurrentY = 1800: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    RsAux.CursorLocation = adUseClient
    '************************* Consulta Antigua ************************
    'Aqui selecciono los sectores y asignaturas correspondientes al nivel del alumno.
    'rsaux.Open "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 order by ord_asi", conn
    '*******************************************************************
    
    '************************* Consulta Nueva 10/06/2005 **************************
    'Esta consulta trae las asignaturas por nivel y letra usando la tabla asi_x_cur_prof como referencia
    'si no tiene profesor asignado no trae la asignatura.
    'RsAux.Open "select * from subsectores s, asi_x_cur_prof ap where s.cod_sec=ap.cod_sec and s.cod_asi=ap.cod_asi and  s.cod_ens = ap.cod_ens  and s.num_gra =  ap.num_gra and ap.cod_ens='" & CodModalidad & "' and ap.num_gra='" & Ngrado & "' and ap.let_cur='" & letra & "' and s.ord_asi <> 0 and ap.agno = " & Cmb_Agno.Text & " order by s.ord_asi", conn
    var_sql = "select * from subsectores s, asi_x_cur_prof ap,notas n" _
            & " Where s.cod_sec = ap.cod_sec And s.cod_asi = ap.cod_asi" _
            & " and  s.cod_ens = ap.cod_ens  and s.num_gra =  ap.num_gra" _
            & " and ap.cod_ens='" & CodModalidad & "' and ap.num_gra='" & Ngrado _
            & "' and ap.let_cur='" & letra & "' and s.ord_asi <> 0 and ap.agno = " & cmb_agno.Text _
            & " and n.agno = ap.agno and n.cod_ens = ap.cod_ens and n.letra_curso = ap.let_cur and n.num_gra = ap.num_gra" _
            & " and n.cod_sec = ap.cod_sec and ci_alu = '" & rutalumno & "'" _
            & " and n.cod_asi = ap.cod_asi and num_per = " & numperiodo _
            & " group by ap.cod_asi" _
            & " order by s.ord_asi"
    RsAux.Open var_sql, conn
    
    promfinal = 0: Sumapromedios = 0
    
    If RsAux.RecordCount > 0 Then 'Si se encontraron asignaturas en el curso
        rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
            While Not RsAux.EOF
                Sector = RsAux("cod_sec")
                Codasi = RsAux("cod_asi")
                Nombreasig = RsAux("nom_asi")
                rsnotas.Open "select cod_sec, cod_asi, num_per, cod_eva, nota from notas where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and num_per = '" & numperiodo & "' and agno = " & cmb_agno.Text & " order by cod_sec, cod_asi", conn
                Aumentosector = Aumentosector + 590
                Printer.CurrentY = 2180 ' OJOJOJOJ ' donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombreasig) ' Imprimo asignatura
                
                Aumentoproceso = Aumentosector '+ 100
                If rsnotas.RecordCount > 0 Then
                    Promsemestre = 0
                    
                    While Not rsnotas.EOF
                        Aumentoproceso = Aumentoproceso + 200
                        Printer.CurrentY = 2150
                        Printer.CurrentY = Printer.CurrentY + Aumentoproceso
                        ydeproceso = Printer.CurrentY - 100
                        notas = rsnotas("nota")
                        evaluacion = DevuelveCampo("evaluaciones", "", "des_eva", "cod_eva = '" & rsnotas("cod_eva") & "'", conn)
                        Porcentaje = DevuelveCampo("evaluaciones", "", "porcentaje_eva", "cod_eva = '" & rsnotas("cod_eva") & "'", conn)
                                                                                                                                                                                                                                                                                                      'MsgBox ("Tipo de evaluacion en fila " & printer.CurrentY & " columna " & printer.CurrentX)
                        'Printer.Line (100, ydeproceso + 50)-(11500, ydeproceso + 50)
                         
                        Printer.FontSize = 7
                        Printer.CurrentX = 600: Printer.Print (evaluacion) ' imprimo tipo evaluación
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 8
                        Printer.CurrentX = 2000: Printer.Print (Porcentaje & "%") ' imprimo porcentaje evaluación
                        aumentonota = 0
                        valnota = 0
                        Promproceso = 0
                        Promponderado = 0
                        Divisor = 0
                        For tnotas = 1 To Len(notas) Step 2
                                notasincoma = Mid(CStr(notas), tnotas, 2)
                                aumentonota = aumentonota + 350
                                Printer.CurrentX = 3400 + aumentonota ' Este valor indica en que posicion empiezan a
                                'Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                                Printer.CurrentY = ydeproceso + 100
                                Printer.FontSize = 9
                                If Len(Trim(notasincoma)) <> 0 Then
                                    'Nota = (notasincoma * 0.1)
                                    Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                                    'Nota = Round(notasincoma * 0.1, 1) 'Mid(notasincoma, 1, 1) & "," & Mid(notasincoma, 2, 1)
                                    valnota = valnota + Nota
                                    If Len(CStr(Nota)) = 1 Then
                                        Nota = " " & Trim(Format(Nota, ".0")) 'Round(CDec(Val(Nota * 1.01)), 1) ' aqui debo dejar un numero entero 4 como 4,0
                                    End If ' sin necesidad de agregarle coma como texto.
                                Divisor = Divisor + 1
                                Else
                                    Nota = " "
                                End If
                                If Nota < 4# Then
                                    Printer.FontBold = True
                                Else
                                    Printer.FontBold = False
                                End If
                                Printer.Print (Nota)
                                Printer.FontBold = False
                        Next tnotas
                        rsnotas.MoveNext
                        If (Len(CStr(notas)) / 2) > 0 Then
                            Promproceso = Format(Int(Round((valnota / Divisor) * 10, 1)) / 10, "0.0")
                            Promponderado = Format((Promproceso * (Porcentaje / 100)), "#0.00")
                            Printer.CurrentY = ydeproceso + 100
                            Printer.CurrentX = 10000
                            Printer.FontSize = 9:
                            'If Len(CStr(Promponderado)) = 1 Then
                            '    Promponderado = " " & Format(Promponderado, ".0")
                            'End If
                            If Me.opt_final_parcial(0).Value Then Printer.Print (Promponderado)
                            Promsemestre = CSng(Promsemestre) + CSng(Promponderado)
                            'Acumular los ponderados
                        End If
                    Wend
                    
                    Promsemestre = Format(Int(Round(Promsemestre * 10, 1)) / 10, "0.0")
                    ' Esta fórmula deja la nota con un entero y un decimal 6,9 - 7,0
                    
                    If Codasi = "13" Then
                        Select Case CSng(Promsemestre)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                        End Select
                    
                    Else
                        If CSng(Promsemestre) > 0 Then
                            Sumapromedios = Sumapromedios + Promsemestre
                            Totalsubsectores = Totalsubsectores + 1
                            If CSng(Promsemestre) < 4# Then
                                Printer.FontBold = True
                            Else
                                Printer.FontBold = False
                            End If
                        Else
                            Promsemestre = ""
                        End If
                    End If
                    
                    'If Promsemestre > 0 Then
                        Printer.CurrentY = ydeproceso '+ 100
                        Printer.CurrentX = 10900
                        'If Len(CStr(Promsemestre)) = 1 Then
                        '    Promsemestre = " " & Format(Promsemestre, ".0")
                        'End If
                        Printer.FontSize = 9
                        
                        If Me.opt_final_parcial(0).Value Then Printer.Print (Promsemestre)
                        Printer.FontBold = False
                    'End If
                    
                Else
                    rs.CursorLocation = adUseClient
                    rs.Open "select des_eva, porcentaje_eva from evaluaciones", conn
                    If rs.RecordCount > 0 Then
                        While Not rs.EOF
                            Aumentoproceso = Aumentoproceso + 200 ' OJO 150
                            Printer.CurrentY = 2140
                            Printer.CurrentY = Printer.CurrentY + Aumentoproceso
                            ydeproceso = Printer.CurrentY - 100
                            'Printer.Line (100, ydeproceso + 50)-(11500, ydeproceso + 50)
                            Printer.FontSize = 7
                            Printer.CurrentX = 600: Printer.Print (rs("des_eva"))
                            Printer.CurrentY = ydeproceso + 100
                            Printer.FontSize = 8
                            Printer.CurrentX = 2000: Printer.Print (rs("porcentaje_eva") & "%")
                            rs.MoveNext
                        Wend
                    End If
                    rs.Close
                    'If CodAsi = "13" Then
                        'Select Case CSng(Promsemestre)
                            'Case 0 To 0.9
                     '           Promsemestre = "EX"
                            'Case 1# To 3.9
                             '   Promsemestre = "I"
                            'Case 4# To 4.9
                            '    Promsemestre = "S"
                            'Case 5# To 5.9
                                'Promsemestre = "B"
                            'Case 6# To 7#
                         '       Promsemestre = "MB"
                        'End Select
                    'End If
                End If
                'Nombreasig = rsaux("nom_asi")
                Printer.Line (50, ydeproceso + 350)-(11500, ydeproceso + 350)
                Aumentosector = Aumentosector + 100
                rsnotas.Close
                RsAux.MoveNext
                avancebarratotal = avancebarratotal + 1
                Me.Prgbar_Notas_curso.Value = Me.Prgbar_Notas_curso.Value + 1
                'Me.Prgbar_Notas_total.Value = Me.Prgbar_Notas_total.Value + 1
                Me.Prgbar_Notas_total.ShowProgress avancebarratotal
                Me.Refresh
                'DoEvents
            Wend
    Printer.CurrentY = ydeproceso + 500
    Printer.CurrentX = 10900
    If Totalsubsectores = 0 Then
        promfinal = ""
    Else
        promfinal = Sumapromedios / Totalsubsectores
        promfinal = Format(Int(Round(promfinal * 10, 1)) / 10, "0.0")
    End If
    If promfinal < 4# Then
        Printer.FontBold = True
    Else
        Printer.FontBold = False
    End If
    Printer.FontSize = 9
    If Me.opt_final_parcial(0).Value Then Printer.Print (promfinal)
    'Printer.Print ("Prom")
    Printer.FontBold = False
    End If
    
    If Me.chk_lineasverticales = 0 Then
        Printer.Line (50, 2700)-(50, ydeproceso + 350)
        Printer.Line (3650, 2700)-(3650, ydeproceso + 350)
        'verti = 4000 ' estas lineas comentadas imprimen las divisiones verticales en las notas
        'For t = 1 To 16
        '    Printer.Line (verti, 2700)-(verti, ydeproceso + 350)
        '    verti = verti + 350
        'Next t
        Printer.Line (9700, 2700)-(9700, ydeproceso + 350)
        Printer.Line (10600, 2700)-(10600, ydeproceso + 350)
        Printer.Line (11500, 2700)-(11500, ydeproceso + 350)
    End If
    Imprimenotasalumno = ydeproceso
    RsAux.Close
End Function
Sub imprimeencabezado()
Call encabezadopapel(True)
' aqui averiguo el tipo del informe, osea final o parcial para
' imprimir el titulo.
If Me.opt_final_parcial(0) Then
    Tipoinforme = UCase(Me.opt_final_parcial(0).Caption)
ElseIf Me.opt_final_parcial(1) Then
    Tipoinforme = UCase(Me.opt_final_parcial(1).Caption)
End If
Printer.FontSize = 9
Call centrarenpapel(1000, Tipoinforme & " " & Me.lst_periodos.Text & " " & cmb_agno.Text)  ' Este año debe ser el de proceso NO DEL SISTEMA
' ACABO DE IMPRIMIR EL TITULO CENTRADO
Printer.FontSize = 8
Printer.CurrentX = 100: Printer.CurrentY = 1400: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 1400: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 1600: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 1600: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 1800: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 1800: Printer.Print (":")

' Este es el cuadrado de la asistencia

Printer.FontBold = False
Printer.Line (50, 2200)-(11500, 2700), , B ' ESTE ES EL PRIMER BOX DEL INFORME

Printer.FontSize = 8
Printer.CurrentX = 100: Printer.CurrentY = 2350: Printer.Print ("A S I G N A T U R A S")
  'printer.FontSize = 1
Printer.CurrentX = 6000: Printer.CurrentY = 2300: Printer.Print ("Calificaciones Parciales")
Aumento = 0
Printer.FontSize = 8
For t = 1 To 17
    Aumento = Aumento + 350
    Printer.CurrentX = 3400
    Printer.CurrentX = Printer.CurrentX + Aumento
    Printer.CurrentY = 2450
    Printer.Print (t)
Next t

Printer.CurrentX = 9800: Printer.CurrentY = 2250: Printer.Print ("Promedio")
Printer.CurrentX = 9800: Printer.CurrentY = 2400: Printer.Print ("Ponderado")
Printer.CurrentX = 10700: Printer.CurrentY = 2250: Printer.Print ("Promedio")
Printer.CurrentX = 10690: Printer.CurrentY = 2400: Printer.Print ("Periodo")
If Me.chk_lineasverticales.Value = 0 Then
    Printer.Line (3650, 2200)-(3650, 2700) ' linea vertical
    Printer.Line (9700, 2200)-(9700, 2700) ' linea vertical
    Printer.Line (10600, 2200)-(10600, 2700) ' linea vertical
End If
End Sub

Sub imprimepie(posicion As Integer, CodModalidad As String, Ngrado As String, letra As String)
' bueno necesito saber el codigo de la modalidad el nivel y la letra porque debo
' imprimir el nombre del profesor jefe.
Dim I As Single

'Aqui empieza a dibujarse todo lo que viene después de las notas
'El 7000 es donde empieza el cuadrado con la información del pie de la página
I = posicion + 400 'Esta variable indica la posición de donde se empezará a dibujar
'el pie de página

Printer.Line (50, I)-(50, I + 400)
Printer.Line (50, I)-(11500, I)
Printer.Line (11500, I)-(11500, I + 400)
Printer.Line (50, I + 400)-(11500, I + 400)

Printer.FontSize = 8
Printer.CurrentX = 200: Printer.CurrentY = I + 650: Printer.Print ("OBSERVACIONES")
Printer.Line (200 + Printer.TextWidth("OBSERVACIONES") + 100, I + 800)-(11500, I + 800)
Printer.Line (200, I + 1100)-(11500, I + 1100)
Printer.CurrentX = 200: Printer.CurrentY = I + 150: Printer.Print ("Atención de Apoderados : ")
'Rescatando rut del profesor
RutProfe = DevuelveCampo("cursos", "", "rut_prof", "agno=" & cmb_agno.Text & " and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'", conn)
'Rescatando nombre completo y horario del profesor
rs.CursorLocation = adUseClient
rs.Open "select noms_prof, ape1_prof, ape2_prof, hor_ate_prof from profesores where rut_prof = '" & RutProfe & "'", conn
If rs.RecordCount Then
    nombreprofe = rs("noms_prof")
    ape1profe = rs("ape1_prof")
    ape2profe = rs("ape2_prof")
    horario = rs("hor_ate_prof")
End If
rs.Close
'Rescatando Nombre completo del(a) director(a)
rs.CursorLocation = adUseClient
rs.Open "select nom_dir, ape_pat_dir, ape_mat_dir from establecimientos", conn
If rs.RecordCount Then
    Nombredir = rs("nom_dir")
    ape1dir = rs("ape_pat_dir")
    ape2dir = rs("ape_mat_dir")
End If
rs.Close

Printer.CurrentX = 2500: Printer.CurrentY = I + 150: Printer.Print (horario)
If Me.opt_final_parcial(0) Then
    modo = Me.opt_final_parcial(0).Caption
Else
    modo = Me.opt_final_parcial(1).Caption
End If

  '  pos = InStr(1, modo, " ")
   ' modo = Mid(modo, pos + 1, (InStr(1, modo, " ")))
    
    'If pos > 1 Then
     '   encab = Mid(modo, 1, pos - 1)
                Listadetablas = Mid(Listadetablas, poscoma + 1, Len(Listadetablas))
         '   ElseIf poscoma = 0 And Len(Listadetablas) > 0 Then
         '       encab = Mid(Listadetablas, 1, Len(Listadetablas))
         '       Listadetablas = ""
   ' End If
        't = t + 1
If Me.opt_final_parcial(0).Value Then
    Printer.CurrentX = 7600: Printer.CurrentY = I + 150: Printer.Print ("PROMEDIO FINAL DEL PERIODO")
End If
'Printer.CurrentX = 200: Printer.CurrentY = i + 350: Printer.Print ("PROMEDIO MAS BAJO DEL CURSO")
'Printer.CurrentX = 200 + Printer.TextWidth("PROMEDIO MAS BAJO DEL CURSO") + 50: Printer.CurrentY = i + 350: Printer.Print (":")
'Printer.CurrentX = 4000: Printer.CurrentY = i + 350: Printer.Print ("PROMEDIO MAS ALTO DEL CURSO")
'Printer.CurrentX = 4000 + Printer.TextWidth("PROMEDIO MAS ALTO DEL CURSO") + 50: Printer.CurrentY = i + 350: Printer.Print (":")
'Printer.CurrentX = 7800: Printer.CurrentY = i + 350: Printer.Print ("PROMEDIO GENERAL DEL CURSO")
'Printer.CurrentX = 7800 + Printer.TextWidth("PROMEDIO GENERAL DEL CURSO") + 50: Printer.CurrentY = i + 350: Printer.Print (":")

'Printer.Line (7200, i + 350)-(11500, i + 350) ' linea vertical separacion promedios
'Printer.Line (7200, i + 550)-(11500, i + 550) ' linea vertical separacion promedios
'Printer.Line (7200, i + 750)-(11500, i + 750) ' linea vertical separacion promedios
'Printer.CurrentX = 300: Printer.CurrentY = i + 480: Printer.Print ("ASISTENCIA")
'Printer.CurrentX = 300: Printer.CurrentY = i + 1050: Printer.Print (Nombreperiodo)
  'printer.FontSize = 10
'Printer.CurrentX = 2500: Printer.CurrentY = i + 400: Printer.Print ("Días")
'Printer.CurrentX = 2500: Printer.CurrentY = i + 600: Printer.Print ("Trabajados")
'Printer.CurrentX = 3500: Printer.CurrentY = i + 400: Printer.Print ("Días")
'Printer.CurrentX = 3500: Printer.CurrentY = i + 600: Printer.Print ("Asistidos")
'Printer.CurrentX = 4500: Printer.CurrentY = i + 400: Printer.Print ("% de")
'Printer.CurrentX = 4500: Printer.CurrentY = i + 600: Printer.Print ("Asistencia")
'Printer.CurrentX = 5500: Printer.CurrentY = i + 400: Printer.Print ("Cantidad de")
'Printer.CurrentX = 5500: Printer.CurrentY = i + 600: Printer.Print ("Atrasos")
If Me.chk_lineasverticales.Value = 0 Then
    'Printer.Line (7200, i)-(7200, i + 100) ' linea vertical separacion horario aten. de promedio
    Printer.Line (10600, I)-(10600, I + 400) ' linea vertical separacion promedios
    'Printer.Line (50, i + 300)-(11500, i + 600), , B ' CUADRADO Promedios del curso
    
Else
    'Printer.Line (50, i + 700)-(11500, i + 700), , B ' LINEA Promedios del curso
End If

Nombreprofejefe = nombreprofe & " " & ape1profe & " " & ape2profe
Cargo1 = "PROFESOR(A) JEFE"
Nombredirec = Nombredir & " " & ape1dir & " " & ape2dir
Cargo2 = "DIRECTOR(A)"
    mitad = (Printer.ScaleWidth / 2) / 2
    largotexto = Printer.TextWidth(Nombreprofejefe)
    linea1 = mitad - (largotexto / 2)
    Printer.Line (linea1, I + 2300)-(linea1 + Printer.TextWidth(Nombreprofejefe), I + 2300) ' linea de firma del profesor jefe
    Printer.CurrentX = linea1: Printer.CurrentY = I + 2350: Printer.Print (Nombreprofejefe)
    largotexto = Printer.TextWidth(Cargo1) ' calculo la posicion del cargo del profe
    linea1 = mitad - (largotexto / 2)
    Printer.CurrentX = linea1: Printer.CurrentY = I + 2500: Printer.Print (Cargo1)
'***************************************************************************************
    mitad = (Printer.ScaleWidth / 2) / 2
    largotexto = Printer.TextWidth(Nombredirec)
    linea2 = mitad - (largotexto / 2) + (Printer.ScaleWidth / 2)
    Printer.Line (linea2, I + 2300)-(linea2 + Printer.TextWidth(Nombredirec), I + 2300) ' linea de firma de la directora
    Printer.CurrentX = linea2: Printer.CurrentY = I + 2350: Printer.Print (Nombredirec)
    largotexto = Printer.TextWidth(Cargo2)
    linea2 = mitad - (largotexto / 2) + (Printer.ScaleWidth / 2)
    Printer.CurrentX = linea2: Printer.CurrentY = I + 2500: Printer.Print (Cargo2)

End Sub
'***** la impresion en pantalla *****

Function Imprimenotasalumnopant(rutalumno As String, Ngrado As String, letra As String, CodModalidad As String, NombreModalidad As String, numperiodo As String) As Integer
'    Dim Promproceso As Single, Promponderado As Single, Promsemestre As Single, valnota As Single   'notasincoma As Single, nota As Single,
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    PP1.FontSize = 8
    PP1.CurrentX = 1600: PP1.CurrentY = 1400: PP1.PrintText (nombres & " " & apaterno & " " & amaterno)
    PP1.CurrentX = 1600: PP1.CurrentY = 1600: PP1.PrintText (Ngrado & " " & letra & " " & UCase(NombreModalidad))
    PP1.CurrentX = 1600: PP1.CurrentY = 1800: PP1.PrintText (nombreapo & " " & ape1apo & " " & ape2apo)
    RsAux.CursorLocation = adUseClient
    var_sql = "select *" _
            & " from subsectores s,asi_x_cur_prof ap" _
            & " where s.num_gra = ap.num_gra and s.cod_asi = ap.cod_asi and s.cod_ens = ap.cod_ens and" _
            & " ap.cod_ens = '" & CodModalidad & "' and ap.num_gra = '" & Ngrado & "' and ord_asi <> 0 and ap.let_cur = '" & letra & "'" _
            & " order by ord_asi"
    'RsAux.Open "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 order by ord_asi", conn
    RsAux.Open var_sql, conn
    'Aqui acabo de seleccionar los sectores y asignaturas
    'correspondientes al nivel del alumno.
    promfinal = 0: Sumapromedios = 0
    If RsAux.RecordCount > 0 Then 'Si se encontraron asignaturas en el curso
        rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
            While Not RsAux.EOF
                Sector = RsAux("cod_sec")
                Codasi = RsAux("cod_asi")
                Nombreasig = RsAux("nom_asi")
                rsnotas.Open "select cod_sec, cod_asi, num_per, cod_eva, nota from notas where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and num_per = '" & numperiodo & "' and agno = " & cmb_agno.Text & " order by cod_sec, cod_asi", conn
                Aumentosector = Aumentosector + 590
                PP1.CurrentY = 2180 ' OJOJOJOJ ' donde se imprime la primera asignatura
                PP1.CurrentY = PP1.CurrentY + Aumentosector
                PP1.CurrentX = 100
                PP1.FontSize = 8
                PP1.PrintText (Nombreasig) ' Imprimo asignatura
                
                Aumentoproceso = Aumentosector '+ 100
                If rsnotas.RecordCount > 0 Then
                    Promsemestre = 0
                    
                    While Not rsnotas.EOF
                        Aumentoproceso = Aumentoproceso + 200
                        PP1.CurrentY = 2150
                        PP1.CurrentY = PP1.CurrentY + Aumentoproceso
                        ydeproceso = PP1.CurrentY - 100
                        notas = rsnotas("nota")
                        evaluacion = DevuelveCampo("evaluaciones", "", "des_eva", "cod_eva = '" & rsnotas("cod_eva") & "'", conn)
                        Porcentaje = DevuelveCampo("evaluaciones", "", "porcentaje_eva", "cod_eva = '" & rsnotas("cod_eva") & "'", conn)
                                                                                                                                                                                                                                                                                                      'MsgBox ("Tipo de evaluacion en fila " & pp1.CurrentY & " columna " & pp1.CurrentX)
                        'pp1.Line (100, ydeproceso + 50)-(11500, ydeproceso + 50)
                         
                        PP1.FontSize = 7
                        PP1.CurrentX = 600: PP1.PrintText (evaluacion) ' imprimo tipo evaluación
                        PP1.CurrentY = ydeproceso + 100
                        PP1.FontSize = 8
                        PP1.CurrentX = 2000: PP1.PrintText (Porcentaje & "%") ' imprimo porcentaje evaluación
                        aumentonota = 0
                        valnota = 0
                        Promproceso = 0
                        Promponderado = 0
                        Divisor = 0
                        For tnotas = 1 To Len(notas) Step 2
                                notasincoma = Mid(CStr(notas), tnotas, 2)
                                aumentonota = aumentonota + 350
                                PP1.CurrentX = 3400 ' Este valor indica en que posicion empiezan a
                                PP1.CurrentX = PP1.CurrentX + aumentonota ' imprimirse las notas
                                PP1.CurrentY = ydeproceso + 100
                                PP1.FontSize = 9
                                If Len(Trim(notasincoma)) <> 0 Then
                                    'Nota = (notasincoma * 0.1)
                                    Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                                    'Nota = Round(notasincoma * 0.1, 1) 'Mid(notasincoma, 1, 1) & "," & Mid(notasincoma, 2, 1)
                                    valnota = valnota + Nota
                                    If Len(CStr(Nota)) = 1 Then
                                        Nota = " " & Trim(Format(Nota, ".0")) 'Round(CDec(Val(Nota * 1.01)), 1) ' aqui debo dejar un numero entero 4 como 4,0
                                    End If ' sin necesidad de agregarle coma como texto.
                                Divisor = Divisor + 1
                                Else
                                    Nota = " "
                                End If
                                If Nota < 4# Then
                                    PP1.FontBold = True
                                Else
                                    PP1.FontBold = False
                                End If
                                PP1.PrintText (Nota)
                                PP1.FontBold = False
                        Next tnotas
                        rsnotas.MoveNext
                        If (Len(CStr(notas)) / 2) > 0 Then
                            Promproceso = Format(Int(Round((valnota / Divisor) * 10, 1)) / 10, "0.0")
                            Promponderado = Format((Promproceso * (Porcentaje / 100)), "#0.00")
                            PP1.CurrentY = ydeproceso + 100
                            PP1.CurrentX = 10000
                            PP1.FontSize = 9:
                            'If Len(CStr(Promponderado)) = 1 Then
                            '    Promponderado = " " & Format(Promponderado, ".0")
                            'End If
                            If Me.opt_final_parcial(0).Value Then PP1.PrintText (Promponderado)
                            Promsemestre = CSng(Promsemestre) + CSng(Promponderado)
                            'Acumular los ponderados
                        End If
                    Wend
                    
                    Promsemestre = Format(Int(Round(Promsemestre * 10, 1)) / 10, "0.0")
                    ' Esta fórmula deja la nota con un entero y un decimal 6,9 - 7,0
                    
                    If Codasi = "13" Then
                        Select Case CSng(Promsemestre)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                        End Select
                    
                    Else
                        If CSng(Promsemestre) > 0 Then
                            Sumapromedios = Sumapromedios + Promsemestre
                            Totalsubsectores = Totalsubsectores + 1
                            If CSng(Promsemestre) < 4# Then
                                PP1.FontBold = True
                            Else
                                PP1.FontBold = False
                            End If
                        Else
                            Promsemestre = ""
                        End If
                    End If
                    
                    'If Promsemestre > 0 Then
                        PP1.CurrentY = ydeproceso '+ 100
                        PP1.CurrentX = 10900
                        'If Len(CStr(Promsemestre)) = 1 Then
                        '    Promsemestre = " " & Format(Promsemestre, ".0")
                        'End If
                        PP1.FontSize = 9
                        
                        If Me.opt_final_parcial(0).Value Then PP1.PrintText (Promsemestre)
                        PP1.FontBold = False
                    'End If
                    
                Else
                    rs.CursorLocation = adUseClient
                    rs.Open "select des_eva, porcentaje_eva from evaluaciones", conn
                    If rs.RecordCount > 0 Then
                        While Not rs.EOF
                            Aumentoproceso = Aumentoproceso + 200 ' OJO 150
                            PP1.CurrentY = 2140
                            PP1.CurrentY = PP1.CurrentY + Aumentoproceso
                            ydeproceso = PP1.CurrentY - 100
                            'pp1.Line (100, ydeproceso + 50)-(11500, ydeproceso + 50)
                            PP1.FontSize = 7
                            PP1.CurrentX = 600: PP1.PrintText (rs("des_eva"))
                            PP1.CurrentY = ydeproceso + 100
                            PP1.FontSize = 8
                            PP1.CurrentX = 2000: PP1.PrintText (rs("porcentaje_eva") & "%")
                            rs.MoveNext
                        Wend
                    End If
                    rs.Close
                    'If CodAsi = "13" Then
                        'Select Case CSng(Promsemestre)
                            'Case 0 To 0.9
                     '           Promsemestre = "EX"
                            'Case 1# To 3.9
                             '   Promsemestre = "I"
                            'Case 4# To 4.9
                            '    Promsemestre = "S"
                            'Case 5# To 5.9
                                'Promsemestre = "B"
                            'Case 6# To 7#
                         '       Promsemestre = "MB"
                        'End Select
                    'End If
                End If
                'Nombreasig = rsaux("nom_asi")
                Call PP1.DrawLine(50, ydeproceso + 350, 11500, ydeproceso + 350)
                Aumentosector = Aumentosector + 100
                rsnotas.Close
                RsAux.MoveNext
                avancebarratotal = avancebarratotal + 1
                Me.Prgbar_Notas_curso.Value = Me.Prgbar_Notas_curso.Value + 1
                'Me.Prgbar_Notas_total.Value = Me.Prgbar_Notas_total.Value + 1
                Me.Prgbar_Notas_total.ShowProgress avancebarratotal
                Me.Refresh
                'DoEvents
            Wend
    PP1.CurrentY = ydeproceso + 500
    PP1.CurrentX = 10900
    If Totalsubsectores = 0 Then
        promfinal = ""
    Else
        promfinal = Sumapromedios / Totalsubsectores
        promfinal = Format(Int(Round(promfinal * 10, 1)) / 10, "0.0")
    End If
    If promfinal < 4# Then
        PP1.FontBold = True
    Else
        PP1.FontBold = False
    End If
    PP1.FontSize = 9
    If Me.opt_final_parcial(0).Value Then PP1.PrintText (promfinal)
    'pp1.Print ("Prom")
    PP1.FontBold = False
    End If
    
    If Me.chk_lineasverticales = 0 Then
        Call PP1.DrawLine(50, 2700, 50, ydeproceso + 350)
        Call PP1.DrawLine(3650, 2700, 3650, ydeproceso + 350)
        'verti = 4000 ' estas lineas comentadas imprimen las divisiones verticales en las notas
        'For t = 1 To 16
        '    pp1.Line (verti, 2700)-(verti, ydeproceso + 350)
        '    verti = verti + 350
        'Next t
        Call PP1.DrawLine(9700, 2700, 9700, ydeproceso + 350)
        Call PP1.DrawLine(10600, 2700, 10600, ydeproceso + 350)
        Call PP1.DrawLine(11500, 2700, 11500, ydeproceso + 350)
    End If
    Imprimenotasalumnopant = ydeproceso
    RsAux.Close
End Function
Sub Imprimeencabezadopant()
Call encabezadopantalla(PP1, True) ' aqui invoco a una funcion que imprime el membrete
' aqui averiguo el tipo del informe, osea final o parcial para
' imprimir el titulo.
If Me.opt_final_parcial(0) Then
    Tipoinforme = UCase(Me.opt_final_parcial(0).Caption)
ElseIf Me.opt_final_parcial(1) Then
    Tipoinforme = UCase(Me.opt_final_parcial(1).Caption)
End If
PP1.FontSize = 9
Call centrarenpantalla(PP1, 1000, Tipoinforme & " " & Me.lst_periodos.Text & " " & cmb_agno.Text)  ' Este año debe ser el de proceso NO DEL SISTEMA
' ACABO DE IMPRIMIR EL TITULO CENTRADO
PP1.FontSize = 8
PP1.CurrentX = 100: PP1.CurrentY = 1400: PP1.PrintText ("ALUMNO"): PP1.CurrentX = 1300: PP1.CurrentY = 1400: PP1.PrintText (":")
PP1.CurrentX = 100: PP1.CurrentY = 1600: PP1.PrintText ("CURSO"): PP1.CurrentX = 1300: PP1.CurrentY = 1600: PP1.PrintText (":")
PP1.CurrentX = 100: PP1.CurrentY = 1800: PP1.PrintText ("APODERADO"): PP1.CurrentX = 1300: PP1.CurrentY = 1800: PP1.PrintText (":")

' Este es el cuadrado de la asistencia

'pp1.Line (5000, 1300)-(11300, 1600), , B  ' CUADRADO DE LA ASISTENCIA

PP1.FontBold = False
Call PP1.DrawBox(50, 2200, 11500, 2700) ', , B ' ESTE ES EL PRIMER BOX DEL INFORME

'pp1.Line (4000, 2200)-(4000, 2700)
PP1.FontSize = 8
PP1.CurrentX = 100: PP1.CurrentY = 2350: PP1.PrintText ("A S I G N A T U R A S")
  'pp1.FontSize = 1
PP1.CurrentX = 6000: PP1.CurrentY = 2300: PP1.PrintText ("Calificaciones Parciales")
Aumento = 0
PP1.FontSize = 8
For t = 1 To 17
    Aumento = Aumento + 350
    PP1.CurrentX = 3400
    PP1.CurrentX = PP1.CurrentX + Aumento
    PP1.CurrentY = 2450
    PP1.PrintText (t)
Next t
'pp1.Line (9300, 2200)-(9300, 2700), B
'pp1.Line (10000, 2200)-(10000, 2700), B
PP1.CurrentX = 9800: PP1.CurrentY = 2250: PP1.PrintText ("Promedio")
PP1.CurrentX = 9800: PP1.CurrentY = 2400: PP1.PrintText ("Ponderado")
PP1.CurrentX = 10700: PP1.CurrentY = 2250: PP1.PrintText ("Promedio")
PP1.CurrentX = 10690: PP1.CurrentY = 2400: PP1.PrintText ("Semestre")

If Me.chk_lineasverticales.Value = 0 Then
    Call PP1.DrawLine(3650, 2200, 3650, 2700)      ' linea vertical
    Call PP1.DrawLine(9700, 2200, 9700, 2700) ' linea vertical
    Call PP1.DrawLine(10600, 2200, 10600, 2700) ' linea vertical
End If
End Sub
Sub imprimepiepant(posicion As Integer, CodModalidad As String, Ngrado As String, letra As String)
' bueno necesito saber el codigo de la modalidad el nivel y la letra porque debo
' imprimir el nombre del profesor jefe.
Dim I As Single, linea1 As Single, linea2 As Single
'Aqui empieza a dibujarse todo lo que viene después de las notas
'El 7000 es donde empieza el cuadrado con la información del pie de la página
I = posicion + 400 'Esta variable indica la posición de donde se empezará a dibujar
'el pie de página

'pp1.Line (50, i)-(11500, i + 1500), , B ' CUADRADO PRINCIPAL
'pp1.Line (50, i)-(11500, i + 300), , B ' CUADRADO atencion de apoderados y promedio final del semstre

Call PP1.DrawLine(50, I, 50, I + 400)
Call PP1.DrawLine(50, I, 11500, I)
Call PP1.DrawLine(11500, I, 11500, I + 400)
Call PP1.DrawLine(50, I + 400, 11500, I + 400)

'pp1.Line (100, i + 400)-(11400, i + 400)
'pp1.Line (6500, i)-(6500, i + 1500)
'pp1.Line (10000, i)-(10000, i + 1500)
'pp1.Line (100, i + 950)-(6500, i + 950)

'pp1.Line (2500, i + 400)-(2500, i + 1500)
'pp1.Line (3500, i + 400)-(3500, i + 1500)
'pp1.Line (4500, i + 400)-(4500, i + 1500)
'pp1.Line (5500, i + 400)-(5500, i + 1500)
PP1.FontSize = 8
PP1.CurrentX = 200: PP1.CurrentY = I + 650: PP1.PrintText ("OBSERVACIONES")
Call PP1.DrawLine(200 + PP1.TextWidth("OBSERVACIONES") + 100, I + 800, 11500, I + 800)
Call PP1.DrawLine(200, I + 1100, 11500, I + 1100)
PP1.CurrentX = 200: PP1.CurrentY = I + 150: PP1.PrintText ("Atención de Apoderados : ")
'Rescatando rut del profesor
RutProfe = DevuelveCampo("cursos", "", "rut_prof", "agno=" & cmb_agno.Text & " and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'", conn)
'Rescatando nombre completo y horario del profesor
rs.CursorLocation = adUseClient
rs.Open "select noms_prof, ape1_prof, ape2_prof, hor_ate_prof from profesores where rut_prof = '" & RutProfe & "'", conn
If rs.RecordCount Then
    nombreprofe = rs("noms_prof")
    ape1profe = rs("ape1_prof")
    ape2profe = rs("ape2_prof")
    horario = rs("hor_ate_prof")
End If
rs.Close
'Rescatando Nombre completo del(a) director(a)
rs.CursorLocation = adUseClient
rs.Open "select nom_dir, ape_pat_dir, ape_mat_dir from establecimientos", conn
If rs.RecordCount Then
    Nombredir = rs("nom_dir")
    ape1dir = rs("ape_pat_dir")
    ape2dir = rs("ape_mat_dir")
End If
rs.Close

PP1.CurrentX = 2500: PP1.CurrentY = I + 150: PP1.PrintText (horario)
If Me.opt_final_parcial(0).Value Then
    PP1.CurrentX = 7600: PP1.CurrentY = I + 150: PP1.PrintText ("PROMEDIO FINAL DEL PERIODO")
End If
'pp1.CurrentX = 200: pp1.CurrentY = i + 350: pp1.Print ("PROMEDIO MAS BAJO DEL CURSO")
'pp1.CurrentX = 200 + pp1.TextWidth("PROMEDIO MAS BAJO DEL CURSO") + 50: pp1.CurrentY = i + 350: pp1.Print (":")
'pp1.CurrentX = 4000: pp1.CurrentY = i + 350: pp1.Print ("PROMEDIO MAS ALTO DEL CURSO")
'pp1.CurrentX = 4000 + pp1.TextWidth("PROMEDIO MAS ALTO DEL CURSO") + 50: pp1.CurrentY = i + 350: pp1.Print (":")
'pp1.CurrentX = 7800: pp1.CurrentY = i + 350: pp1.Print ("PROMEDIO GENERAL DEL CURSO")
'pp1.CurrentX = 7800 + pp1.TextWidth("PROMEDIO GENERAL DEL CURSO") + 50: pp1.CurrentY = i + 350: pp1.Print (":")

'pp1.Line (7200, i + 350)-(11500, i + 350) ' linea vertical separacion promedios
'pp1.Line (7200, i + 550)-(11500, i + 550) ' linea vertical separacion promedios
'pp1.Line (7200, i + 750)-(11500, i + 750) ' linea vertical separacion promedios
'pp1.CurrentX = 300: pp1.CurrentY = i + 480: pp1.Print ("ASISTENCIA")
'pp1.CurrentX = 300: pp1.CurrentY = i + 1050: pp1.Print (Nombreperiodo)
  'pp1.FontSize = 10
'pp1.CurrentX = 2500: pp1.CurrentY = i + 400: pp1.Print ("Días")
'pp1.CurrentX = 2500: pp1.CurrentY = i + 600: pp1.Print ("Trabajados")
'pp1.CurrentX = 3500: pp1.CurrentY = i + 400: pp1.Print ("Días")
'pp1.CurrentX = 3500: pp1.CurrentY = i + 600: pp1.Print ("Asistidos")
'pp1.CurrentX = 4500: pp1.CurrentY = i + 400: pp1.Print ("% de")
'pp1.CurrentX = 4500: pp1.CurrentY = i + 600: pp1.Print ("Asistencia")
'pp1.CurrentX = 5500: pp1.CurrentY = i + 400: pp1.Print ("Cantidad de")
'pp1.CurrentX = 5500: pp1.CurrentY = i + 600: pp1.Print ("Atrasos")
If Me.chk_lineasverticales.Value = 0 Then
    'pp1.Line (7200, i)-(7200, i + 100) ' linea vertical separacion horario aten. de promedio
    Call PP1.DrawLine(10600, I, 10600, I + 400)      ' linea vertical separacion promedios
    'pp1.Line (50, i + 300)-(11500, i + 600), , B ' CUADRADO Promedios del curso
    
Else
    'pp1.Line (50, i + 700)-(11500, i + 700), , B ' LINEA Promedios del curso
End If

Nombreprofejefe = nombreprofe & " " & ape1profe & " " & ape2profe
Cargo1 = "PROFESOR(A) JEFE"
Nombredirec = Nombredir & " " & ape1dir & " " & ape2dir
Cargo2 = "DIRECTOR(A)"
    mitad = (PP1.ScaleWidth / 2) / 2
    largotexto = PP1.TextWidth(Nombreprofejefe)
    linea1 = mitad - (largotexto / 2)
    Call PP1.DrawLine(linea1, I + 2300, linea1 + PP1.TextWidth(Nombreprofejefe), I + 2300) ' linea de firma del profesor jefe
    PP1.CurrentX = linea1: PP1.CurrentY = I + 2350: PP1.PrintText (Nombreprofejefe)
    largotexto = PP1.TextWidth(Cargo1) ' calculo la posicion del cargo del profe
    linea1 = mitad - (largotexto / 2)
    PP1.CurrentX = linea1: PP1.CurrentY = I + 2500: PP1.PrintText (Cargo1)
'***************************************************************************************
    mitad = (PP1.ScaleWidth / 2) / 2
    largotexto = PP1.TextWidth(Nombredirec)
    linea2 = mitad - (largotexto / 2) + (PP1.ScaleWidth / 2)
    Call PP1.DrawLine(linea2, I + 2300, linea2 + PP1.TextWidth(Nombredirec), I + 2300) ' linea de firma de la directora
    PP1.CurrentX = linea2: PP1.CurrentY = I + 2350: PP1.PrintText (Nombredirec)
    largotexto = PP1.TextWidth(Cargo2)
    linea2 = mitad - (largotexto / 2) + (PP1.ScaleWidth / 2)
    PP1.CurrentX = linea2: PP1.CurrentY = I + 2500: PP1.PrintText (Cargo2)

End Sub
Private Sub btn_ace_mat_nuevo_Click()
    Me.Enabled = False
If Me.Opt_mat_nuevos(0) Then
    ManTab = "mat"
    
    
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    var_sql = "select valor from cfg where param = 'CODBC'"
    objRS.Open var_sql, conn
        var_sql = objRS("valor")
    objRS.Close
    If var_sql = "HUE001" Or var_sql = "ALT001" Then
        Load Form_proc_Cursos_hue
    Else
        Load Form_proc_Cursos
    End If
    
    
Else
    'Load Form_MatriReserv2
End If
End Sub

Private Sub btn_acep_vacantes_Click()
If Me.Opt_vacantes(0).Value Then
    Escenario = 1
ElseIf Me.Opt_vacantes(1).Value Then
    Escenario = 2
ElseIf Me.Opt_vacantes(2).Value Then
    Escenario = 3
End If
Menuinformes5 = "vacantes"
Load Form_Proyec_Vac
End Sub

Private Sub Btn_Can_CambioCurso_Click()
Set rs = Nothing
Unload Me
End Sub

Private Sub btn_can_cursos_Click()
Set rs = Nothing
Unload Me
End Sub

Private Sub btn_can_emat_Click()
Unload Me
End Sub

Private Sub btn_can_mat_nuevo_Click()
Unload Me
End Sub

Private Sub btn_can_notas_Click()
Unload Me
End Sub

Private Sub BTN_CAN_REGMATRI_Click()
Set rs = Nothing
Unload Me
End Sub

Private Sub Btn_can_vacantes_Click()
Unload Me
End Sub

Private Sub Btn_gen_reportes_Click()
Dim var_sql As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
Dim fechainicio As String
Dim fechafin As String
cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)

If Me.cmb_mod_cambiocurso.Text <> "" And Me.Cmb_Mes_ini.Text <> "" And Me.Cmb_Mes_fin.Text <> "" Then
    rs.CursorLocation = adUseClient
    rs.Open "select Nom_dir_sub,ape_pat_dir_sub,ape_mat_dir_sub,nom_sostenedor, rut_sostenedor, rut_est, nom_est, dir_est, localidad_est, rut_director_est, nom_dir, ape_pat_dir, ape_mat_dir, Rut_Rep_legal, Nom_Rep_legal, ape_pat_rep_legal, ape_mat_rep_legal, dec_coop, fec_dec_coop from establecimientos", conn
    If rs.RecordCount > 0 Then
        rutcol = rs("rut_est")
        Nombrecol = rs("Nom_est")
        Direccol = rs("Dir_est")
        ComunaCol = rs("Localidad_est")
        nomreplegal = rs("Nom_rep_legal") & " " & rs("ape_pat_rep_legal") & " " & rs("ape_mat_rep_legal")
        rutreplegal = rs("Rut_Rep_legal")
        rutdir = rs("rut_director_est")
        If cole = "PUD001" Then
            nomdir = rs("Nom_dir_sub") & " " & rs("ape_pat_dir_sub") & " " & rs("ape_mat_dir_sub")
        Else
            nomdir = rs("Nom_dir") & " " & rs("ape_pat_dir") & " " & rs("ape_mat_dir")
        End If
        deccoop = rs("dec_coop")
        fechadecoop = rs("fec_dec_coop")
        nomsost = rs("nom_sostenedor")
        rutsost = rs("rut_sostenedor")
    End If
    rs.Close
    Form_main.CrystalReport.Formulas(0) = "nombrecolegio = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "direccioncolegio = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacolegio = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "hora = '" & Time & "'"
    Form_main.CrystalReport.Formulas(4) = "nomreprelegal = '" & nomreplegal & "'"
    Form_main.CrystalReport.Formulas(5) = "rutreprelegal = '" & rutreplegal & "'"
    Form_main.CrystalReport.Formulas(6) = "nomsost = '" & nomsost & "'"
    Form_main.CrystalReport.Formulas(7) = "rutsost = '" & rutsost & "'"
    Form_main.CrystalReport.Formulas(8) = "rutdirec = '" & rutdir & "'"
    Form_main.CrystalReport.Formulas(9) = "nomdirec = '" & nomdir & "'"
    Form_main.CrystalReport.Formulas(10) = "DecCooper = '" & deccoop & "'"
    Form_main.CrystalReport.Formulas(11) = "FecDecCooper = '" & fechadecoop & "'"

    'fechainicio = Format(Anno & "," + ameses(Me.Cmb_Mes_Ini.ListIndex + 1, 2), "yyyy-mm-dd")
    'fechafin = Format(Anno & "," + ameses(Me.Cmb_Mes_Fin.ListIndex + 1 + Me.Cmb_Mes_Ini.ListIndex, 3), "yyyy-mm-dd")
    fechainicio = Anno & "," + ameses(Me.Cmb_Mes_ini.ListIndex + 1, 2)
    fechafin = Anno & "," + ameses(Me.Cmb_Mes_fin.ListIndex + 1 + Me.Cmb_Mes_ini.ListIndex, 3)
    Codens = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_mod_cambiocurso & "'", conn)
'
'    var_sql = "update alu_x_cur set ens = '010' where (cod_ens = '010' or cod_ens = '996') and agno = 2012;"
'    conn.Execute var_sql
'    var_sql = "update matriculas set ens = '010' where (cod_ens = '010' or cod_ens = '996') and anno_mat = 2012;"
'    conn.Execute var_sql
'    var_sql = "update alu_x_cur set ens = cod_ens,gra = num_gra,pre = num_gra where (cod_ens = '110' or cod_ens = '310') and agno = 2009;"
'    conn.Execute var_sql
'    var_sql = "update matriculas set ens = cod_ens,gra = num_gra,pre = num_gra where (cod_ens = '110' or cod_ens = '310') and anno_mat = 2009;"
'    conn.Execute var_sql
'var_sql = "update alu_x_cur set ens = '010' where (cod_ens = '010' or cod_ens = '996') and agno = 2009;"
'conn.Execute var_sql
'var_sql = "update matriculas set ens = '010' where (cod_ens = '010' or cod_ens = '996') and anno_mat = 2009;"
'conn.Execute var_sql
'var_sql = "update matriculas set gra = 4,pre = 'PK' where cod_ens = '996' and anno_mat = 2009;"
'conn.Execute var_sql
'var_sql = "update matriculas set gra = 5,pre = 'K' where cod_ens = '010' and anno_mat = 2009;"
'conn.Execute var_sql
'var_sql = "update alu_x_cur set gra = 4,pre = 'PK' where cod_ens = '996' and agno = 2009;"
'conn.Execute var_sql
'var_sql = "update alu_x_cur set gra = 5,pre = 'K' where cod_ens = '010' and agno = 2009;"
'conn.Execute var_sql
      
      
'var_sql = "update alu_x_cur set ens = '010' where cod_ens = '996' and agno = " & Anno & ";"
'conn.Execute var_sql
'var_sql = "update matriculas set ens = '010' where cod_ens = '996' and anno_mat = " & Anno & ";"
'conn.Execute var_sql
var_sql = "update alu_x_cur set ens = cod_ens,gra = num_gra,pre = num_gra where (cod_ens = '010' or cod_ens = '110' or cod_ens = '310') and agno = " & Anno & ";"
conn.Execute var_sql
var_sql = "update matriculas set ens = cod_ens,gra = num_gra,pre = num_gra where (cod_ens = '010' or cod_ens = '110' or cod_ens = '310') and anno_mat = " & Anno & ";"
conn.Execute var_sql
var_sql = "update alu_x_cur set ens = '010' where cod_ens = '996' and agno = " & Anno & ";"
conn.Execute var_sql
var_sql = "update matriculas set ens = '010' where cod_ens = '996' and anno_mat = " & Anno & ";"
conn.Execute var_sql

var_sql = "update alu_x_cur set ens = '111' where cod_ens = '111' and agno = " & Anno & ";"
conn.Execute var_sql
var_sql = "update matriculas set ens = '111' where cod_ens = '111' and anno_mat = " & Anno & ";"
conn.Execute var_sql
var_sql = "update matriculas set gra = 3,pre = 'PG' where cod_ens = '111' and anno_mat = " & Anno & ";"
conn.Execute var_sql
var_sql = "update alu_x_cur set gra = 3,pre = 'PG' where cod_ens = '111' and agno = " & Anno & ";"
conn.Execute var_sql


var_sql = "update matriculas set gra = 4,pre = 'PK' where cod_ens = '996' and anno_mat = " & Anno & ";"
conn.Execute var_sql
var_sql = "update matriculas set gra = 5,pre = 'K' where cod_ens = '010' and anno_mat = " & Anno & ";"
conn.Execute var_sql
var_sql = "update alu_x_cur set gra = 4,pre = 'PK' where cod_ens = '996' and agno = " & Anno & ";"
conn.Execute var_sql
var_sql = "update alu_x_cur set gra = 5,pre = 'K' where cod_ens = '010' and agno = " & Anno & ";"
conn.Execute var_sql
 
      
      
        'If Cod_Ens = "996" Then Cod_Ens = "010"
    
            'realizamos actualizacion de datos de nombre de papa y mama antes de imprimir
            'se modifico 12-05-2022
            var_sql = ""
            var_sql = var_sql & " UPDATE  POSTULANTES P, APODERADOS A"
            var_sql = var_sql & " SET P.NOM_PAD_ALU =  CONCAT(A.APE1_APO, ' ',  A.APE2_APO, ' ', A.NOMS_APO)"
            var_sql = var_sql & " Where p.RUT_PAD_ALU = a.rut_apo"
            conn.Execute var_sql

            var_sql = ""
            var_sql = var_sql & " UPDATE  POSTULANTES P, APODERADOS A"
            var_sql = var_sql & " SET P.NOM_MAD_ALU =  CONCAT(A.APE1_APO, ' ',  A.APE2_APO, ' ', A.NOMS_APO)"
            var_sql = var_sql & " Where p.RUT_MAD_ALU = a.rut_apo"
            conn.Execute var_sql

    
    
    
    
    Dim FecMatINNI As String
    FecMatINI = RetornaCampo("CFG", "valor", "Param='PerEscIni' and agno=" & Anno, conn)
    If MenuInformes = "cambiocurso" Then
        titulo = "REGISTRO DE ALTAS Y BAJAS POR CAMBIOS DE CURSO " & Me.cmb_mod_cambiocurso.Text
        Form_main.CrystalReport.WindowTitle = "Registro cambios de curso " & Me.cmb_mod_cambiocurso.Text
        Form_main.CrystalReport.Formulas(13) = "TITULO = '" & UCase(titulo) & "'"
        
        'se cambio de posicion para probar 13-05-2022
        If cole = "PUD001" Then
            Form_main.CrystalReport.Formulas(14) = "dir_sub = '" & "DIRECTORA SUBROGANTE" & "'"
        Else
            Form_main.CrystalReport.Formulas(14) = "dir_sub = '" & "DIRECTOR(A)" & "'"
        End If

        Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\cambiocurso.rpt"
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
        Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_CAM}  >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_CAM} <= '" & Format(fechafin, "yyyy-mm-dd") & "' and {alu_x_cur.AGNO}=" & Anno & "")
        Form_main.CrystalReport.WindowState = crptMaximized
        Form_main.CrystalReport.Action = 1
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
        Call LimpiaFormulas(Form_main.CrystalReport, 30)
    ElseIf MenuInformes = "registroaltas" Then
    
        titulo = "REGISTRO DE ALTAS DE LA MATRÍCULA " & Me.cmb_mod_cambiocurso.Text
        Form_main.CrystalReport.WindowTitle = "Registro de matrículas con Altas " & Me.cmb_mod_cambiocurso.Text
        Form_main.CrystalReport.Formulas(12) = "TITULO = '" & UCase(titulo) & "'"
        Form_main.CrystalReport.Formulas(13) = "Orden  = {alu_x_cur.FEC_ALTA}"
        Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\registro_altas_bajas.rpt"
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
      
       
        
        var_sql = "SELECT nombre,colegio" _
                    & " From hist_cod_colegio" _
                    & " where colegio = (select valor from cfg where param = 'codbc')"
            objRS.Open var_sql, conn
            colegio = objRS("colegio")
            nombre = objRS("nombre")
            objRS.Close
            
            
            
            If colegio = "LON001" Then
                Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_ING_CURSO} >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_ALTA} <> '" & FecMatINI & "' and {alu_x_cur.FEC_ALTA} <= '" & Format(fechafin, "yyyy-mm-dd") & "' And  {alu_x_cur.AGNO}=" & Anno & " AND {alu_x_cur.CAMBIO}='NO' and {alu_x_cur.fec_alta} > '" & FecMatINI & "' and {matriculas.num_mat} <> '00000'")
            End If
            If colegio = "SNM001" Then
                Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_ING_CURSO} >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_ALTA} <> '" & FecMatINI & "' and {alu_x_cur.FEC_ALTA} <= '" & Format(fechafin, "yyyy-mm-dd") & "' And  {alu_x_cur.AGNO}=" & Anno & " AND {alu_x_cur.CAMBIO}='NO' and {alu_x_cur.fec_alta} > '" & FecMatINI & "' and {matriculas.num_mat} <> '00000'")
            End If
            If colegio = "FAR001" Then
                Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_ING_CURSO} >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_ALTA} <> '" & FecMatINI & "' and {alu_x_cur.FEC_ALTA} <= '" & Format(fechafin, "yyyy-mm-dd") & "' And  {alu_x_cur.AGNO}=" & Anno & " AND {alu_x_cur.CAMBIO}='NO' and {alu_x_cur.fec_alta} > '" & FecMatINI & "' and {matriculas.num_mat} <> '00000'")
            End If
            If colegio = "LIN001" Then
                Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_ING_CURSO} >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_ALTA} <> '" & FecMatINI & "' and {alu_x_cur.FEC_ALTA} <= '" & Format(fechafin, "yyyy-mm-dd") & "' And  {alu_x_cur.AGNO}=" & Anno & " AND {alu_x_cur.CAMBIO}='NO' and {alu_x_cur.fec_alta} > '" & FecMatINI & "' and {matriculas.num_mat} <> '00000'")
            End If
            If colegio = "FLO001" Then
                Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_ING_CURSO} >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_ALTA} <> '" & FecMatINI & "' and {alu_x_cur.FEC_ALTA} <= '" & Format(fechafin, "yyyy-mm-dd") & "' And  {alu_x_cur.AGNO}=" & Anno & " AND {alu_x_cur.CAMBIO}='NO' and {alu_x_cur.fec_alta} > '" & FecMatINI & "' and {matriculas.num_mat} <> '00000'")
            End If
            If colegio = "PUD001" Then
                Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_ING_CURSO} >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_ALTA} <> '" & FecMatINI & "' and {alu_x_cur.FEC_ALTA} <= '" & Format(fechafin, "yyyy-mm-dd") & "' And  {alu_x_cur.AGNO}=" & Anno & " AND {alu_x_cur.CAMBIO}='NO' and {alu_x_cur.fec_alta} > '" & FecMatINI & "' and {matriculas.num_mat} <> '00000'")
            End If
            If colegio = "SNB001" Then
                Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_ING_CURSO} >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_ALTA} <> '" & FecMatINI & "' and {alu_x_cur.FEC_ALTA} <= '" & Format(fechafin, "yyyy-mm-dd") & "' And  {alu_x_cur.AGNO}=" & Anno & " AND {alu_x_cur.CAMBIO}='NO' and {alu_x_cur.fec_alta} > '" & FecMatINI & "' and {matriculas.num_mat} <> '00000'")
            End If
            If colegio = "HUE001" Then
                Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {alu_x_cur.FEC_ING_CURSO} >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {alu_x_cur.FEC_ALTA} <> '" & FecMatINI & "' and {alu_x_cur.FEC_ALTA} <= '" & Format(fechafin, "yyyy-mm-dd") & "' And  {alu_x_cur.AGNO}=" & Anno & " AND {alu_x_cur.CAMBIO}='NO' and {alu_x_cur.fec_alta} > '" & FecMatINI & "' and {matriculas.num_mat} <> '00000'")
            End If
               
        Form_main.CrystalReport.WindowState = crptMaximized
        Form_main.CrystalReport.Action = 1
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
        
        Call LimpiaFormulas(Form_main.CrystalReport, 30)
    ElseIf MenuInformes = "registrobajas" Then
        titulo = "REGISTRO DE BAJAS DE LA MATRÍCULA " & Me.cmb_mod_cambiocurso.Text
        Form_main.CrystalReport.WindowTitle = "Registro de matrículas con Bajas " & Me.cmb_mod_cambiocurso.Text
        Form_main.CrystalReport.Formulas(12) = "TITULO = '" & UCase(titulo) & "'"
        Form_main.CrystalReport.Formulas(13) = "Orden  = {matriculas.FEC_RETIRO}"
        
        
       
        Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\registro_altas_bajas_retiro.rpt"
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
        Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {matriculas.FEC_RETIRO}  >= '" & Format(fechainicio, "yyyy-mm-dd") & "' and {matriculas.FEC_RETIRO} <= '" & Format(fechafin, "yyyy-mm-dd") & "' and {matriculas.activo_alu}={alu_x_cur.activo_alu} and {matriculas.activo_alu}='NO' and {alu_x_cur.fec_cam}='1111-11-11' and {alu_x_cur.AGNO}=" & Anno & "")
        Form_main.CrystalReport.WindowState = crptMaximized
        Form_main.CrystalReport.Action = 1
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
        Call LimpiaFormulas(Form_main.CrystalReport, 30)
    End If
Else
    MsgBox ("Faltan opciones por seleccionar")
End If
End Sub

Sub ordensubsectores()
'****************************
'HAY QUE MATAR EL CODIGO MULA
 Exit Sub
'MUERE!!!
'*******************************************************************************************************
'Primero Básico
If ExistReg("subsectores", "cod_asi ='19' and cod_ens='110' and num_gra='1'", conn) Then
    conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '19' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '15' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '16' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '17' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '18' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '11' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '13' and cod_ens='110' and num_gra='1'"
Else
    conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '15' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '16' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '17' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '18' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '11' and cod_ens='110' and num_gra='1'"
    conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '13' and cod_ens='110' and num_gra='1'"
End If
'*******************************************************************************************************
'Segundo Básico
If ExistReg("subsectores", "cod_asi ='19' and cod_ens='110' and num_gra='2'", conn) Then
    conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '19' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '15' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '16' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '17' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '18' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '11' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '13' and cod_ens='110' and num_gra='2'"
Else
    conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '15' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '16' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '17' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '18' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '11' and cod_ens='110' and num_gra='2'"
    conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '13' and cod_ens='110' and num_gra='2'"
End If
'*******************************************************************************************************
'Tercero Básico
If ExistReg("subsectores", "cod_asi ='19' and cod_ens='110' and num_gra='3'", conn) Then
    conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '19' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '15' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '16' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '17' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '18' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '11' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '13' and cod_ens='110' and num_gra='3'"
Else
    conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '15' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '16' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '17' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '18' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '11' and cod_ens='110' and num_gra='3'"
    conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '13' and cod_ens='110' and num_gra='3'"
End If
'*******************************************************************************************************
'Cuarto Básico
If ExistReg("subsectores", "cod_asi ='19' and cod_ens='110' and num_gra='4'", conn) Then
    conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '19' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '15' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '16' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '17' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '18' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '11' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '13' and cod_ens='110' and num_gra='4'"
Else
    conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '15' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '16' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '17' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '18' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '11' and cod_ens='110' and num_gra='4'"
    conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '13' and cod_ens='110' and num_gra='4'"
End If
'*******************************************************************************************************
'Quinto Básico
conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='5'"
conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '19' and cod_ens='110' and num_gra='5'"
conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '15' and cod_ens='110' and num_gra='5'"
conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '20' and cod_ens='110' and num_gra='5'"
conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '21' and cod_ens='110' and num_gra='5'"
conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '17' and cod_ens='110' and num_gra='5'"
conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '18' and cod_ens='110' and num_gra='5'"
conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '11' and cod_ens='110' and num_gra='5'"
conn.Execute "update subsectores set ord_asi = 9 where cod_asi = '13' and cod_ens='110' and num_gra='5'"
'*******************************************************************************************************
'Sexto Básico
conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='6'"
conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '19' and cod_ens='110' and num_gra='6'"
conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '15' and cod_ens='110' and num_gra='6'"
conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '20' and cod_ens='110' and num_gra='6'"
conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '21' and cod_ens='110' and num_gra='6'"
conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '17' and cod_ens='110' and num_gra='6'"
conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '18' and cod_ens='110' and num_gra='6'"
conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '11' and cod_ens='110' and num_gra='6'"
conn.Execute "update subsectores set ord_asi = 9 where cod_asi = '13' and cod_ens='110' and num_gra='6'"
'*******************************************************************************************************
'Septimo Básico
conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '36' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '15' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '20' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '21' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '17' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '28' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '29' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 9 where cod_asi = '11' and cod_ens='110' and num_gra='7'"
conn.Execute "update subsectores set ord_asi = 10 where cod_asi = '13' and cod_ens='110' and num_gra='7'"
'*******************************************************************************************************
'Octavo Básico
conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '14' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '36' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '15' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '21' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '20' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '17' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '28' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '29' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 9 where cod_asi = '11' and cod_ens='110' and num_gra='8'"
conn.Execute "update subsectores set ord_asi = 10 where cod_asi = '13' and cod_ens='110' and num_gra='8'"
'*******************************************************************************************************
'Primero Medio
conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '27' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '36' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '5' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '35' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '3' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '7' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '8' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '37' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 9 where cod_asi = '17' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 10 where cod_asi = '11' and cod_ens='310' and num_gra='1'"
conn.Execute "update subsectores set ord_asi = 11 where cod_asi = '13' and cod_ens='310' and num_gra='1'"
'*******************************************************************************************************
'Segundo Medio
conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '27' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '36' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '5' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '35' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '8' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '3' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '7' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '37' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 9 where cod_asi = '17' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 10 where cod_asi = '11' and cod_ens='310' and num_gra='2'"
conn.Execute "update subsectores set ord_asi = 11 where cod_asi = '13' and cod_ens='310' and num_gra='2'"
'*******************************************************************************************************
'Tercero Medio
conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '27' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '36' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '2197' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '5' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '2198' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '35' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '2199' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '999' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 9 where cod_asi = '2200' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 10 where cod_asi = '8' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 11 where cod_asi = '3' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 12 where cod_asi = '2264' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 13 where cod_asi = '7' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 14 where cod_asi = '2216' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 15 where cod_asi = '37' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 16 where cod_asi = '28' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 17 where cod_asi = '2743' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 18 where cod_asi = '11' and cod_ens='310' and num_gra='3'"
conn.Execute "update subsectores set ord_asi = 19 where cod_asi = '13' and cod_ens='310' and num_gra='3'"
'Cuarto Medio
conn.Execute "update subsectores set ord_asi = 1 where cod_asi = '27' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 2 where cod_asi = '36' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 3 where cod_asi = '2197' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 4 where cod_asi = '5' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 5 where cod_asi = '2687' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 6 where cod_asi = '35' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 7 where cod_asi = '2214' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 8 where cod_asi = '999' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 9 where cod_asi = '3' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 10 where cod_asi = '8' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 11 where cod_asi = '2007' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 12 where cod_asi = '2266' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 13 where cod_asi = '37' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 14 where cod_asi = '2217' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 15 where cod_asi = '11' and cod_ens='310' and num_gra='4'"
conn.Execute "update subsectores set ord_asi = 16 where cod_asi = '13' and cod_ens='310' and num_gra='4'"
End Sub

Private Sub btn_impri_notas_Click()
Dim des_ens As String
'Dim colegio As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
Dim var_sql As String
Dim cor As Long
Dim Con As Integer, coordenada As Integer
Dim PosImprInfFinal As Integer

'On Error GoTo Errorimpresion 'Configura el controlador de errores.
If Me.opt_indiv_gral(0) Then 'Si informe es individual
    If Me.lst_periodos.ListIndex >= 0 And Me.txt_rut_alu.Text <> "" And Me.cmb_fuentes.Text <> "" And Me.cmb_printers.Text <> "" Then
        If Me.Opt_destino(1).Value Then
            PP1.FontName = Me.cmb_fuentes.Text
            If Me.opt_tipopapel(0).Value = True Then
                PP1.PageSize = ppLetter '1 es Carta
            ElseIf Me.opt_tipopapel(1).Value = True Then
                PP1.PageSize = ppLegal  'Es Oficio
            End If
        Else
            Printer.FontName = Me.cmb_fuentes.Text
            If Me.opt_tipopapel(0).Value = True Then
                Printer.PaperSize = 1 'es Carta
            ElseIf Me.opt_tipopapel(1).Value = True Then
                Printer.PaperSize = 5 '1 Es Oficio
            End If
        End If
        ' aqui debo validar que hayan seleccionado todos los criterios
        modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.txt_mod_alu.Text & "'", conn)
        numperiodo = aperiodos(Me.lst_periodos.ListIndex)
        '****************** Consulta antigua ***************************
        '***************************************************************
        
        '****************** Consulta Nueva 10/06/2005 ******************
        'Esta consulta trae las asignaturas por nivel y letra usando la tabla asi_x_cur_prof como referencia
        'si no tiene profesor asignado no trae la asignatura
         asignaturas = CuentaReg("subsectores s, asi_x_cur_prof ap", "s.cod_sec=ap.cod_sec and s.cod_asi=ap.cod_asi and  s.cod_ens = ap.cod_ens  and s.num_gra =  ap.num_gra and ap.cod_ens='" & modalidad & "' and ap.num_gra='" & Me.txt_nivel_alu.Text & "' and ap.let_cur='" & Me.txt_letra_alu & "' and s.ord_asi <> 0 and ap.agno = " & cmb_agno.Text & " order by s.ord_asi", conn)
        
        
        If asignaturas > 0 Then
        
             '*********************** Informe Talleres ***********************
            var_sql = "select valor from cfg where param = 'CODBC'"
            objRS.Open var_sql, conn
            colegio = objRS("valor")
            objRS.Close
            
'            If colegio = "HUE001" And lst_periodos.Text = "ANUAL" Then
'                MsgBox "EL INFORME ANUAL SOLO PUEDE SER OBTENIDO A TRAVES DE LA PAGINA WEB", vbInformation
'                Exit Sub
'            End If
            
            If Not (numperiodo = "666") Then
                If (colegio = "ALT001" Or colegio = "HUE001") And lst_periodos.Text <> "ANUAL" Then
                    Printer.Orientation = vbPRORPortrait
                    Imprimeencabezadopant_hue
                                
                    If colegio = "HUE001" Then
                        cor = Imprimenotasalumnopant_hue(txt_rut_alu.Text, txt_nivel_alu.Text, txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo)
                        Call imprimepiepant_hue(txt_rut_alu.Text, CInt(cor), modalidad, txt_nivel_alu.Text, txt_letra_alu.Text)
                    Else
                        cor = Imprimenotasalumnopant_alt(txt_rut_alu.Text, txt_nivel_alu.Text, txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo)
                        Call imprimepiepant_hue(txt_rut_alu.Text, CInt(cor), modalidad, txt_nivel_alu.Text, txt_letra_alu.Text)
                    End If
                
                    Printer.EndDoc
                    Exit Sub
                Else
                    Printer.Orientation = vbPRORPortrait
                    If colegio = "SNB001" Then
                        If txt_nivel_alu.Text < 7 And modalidad = "110" Then
                            Imprimeencabezadopant_tall_formativa (0)
                            cor = Imprimenotasalumnopant_tall_formativa(txt_rut_alu.Text, txt_nivel_alu.Text, txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo, 0)
                            Call imprimepiepant_tall(CInt(cor), modalidad, txt_nivel_alu.Text, txt_letra_alu.Text)
                            Printer.NewPage
                            'Printer.Orientation = vbPRORPortrait
                            Imprimeencabezadopant_tall_formativa (1)
                            cor = Imprimenotasalumnopant_tall_formativa(txt_rut_alu.Text, txt_nivel_alu.Text, txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo, 1)
                            'Call imprimepiepant_tall(CInt(cor), modalidad, txt_nivel_alu.Tex       t, txt_letra_alu.Text)
                        Else
                            Imprimeencabezadopant_sanbe (0)
                            cor = Imprimenotasalumnopant_sanbe(txt_rut_alu.Text, txt_nivel_alu.Text, txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo, 0)
                            Call imprimepiepant_tall(CInt(cor), modalidad, txt_nivel_alu.Text, txt_letra_alu.Text)
                            Printer.NewPage
                            Imprimeencabezadopant_sanbe (1)
                            cor = Imprimenotasalumnopant_sanbe(txt_rut_alu.Text, txt_nivel_alu.Text, txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo, 1)
                        End If
                    Else
                        Imprimeencabezadopant_tall
                        cor = Imprimenotasalumnopant_tall(txt_rut_alu.Text, txt_nivel_alu.Text, txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo)
                        Call imprimepiepant_tall(CInt(cor), modalidad, txt_nivel_alu.Text, txt_letra_alu.Text)
                    End If
                    
                    Call imprimepiepant_tall(CInt(cor), modalidad, txt_nivel_alu.Text, txt_letra_alu.Text)
                
                    Printer.EndDoc
                    Exit Sub
                End If
            Else
LabelImprInfoFinal:
                    Printer.Orientation = vbPRORLandscape
                    If lst_periodos.Text = "ANUAL" Then
                        If colegio = "SNB001" Then
                            ImprimeInformeFinalCab_tall_sumativa Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_mod_alu.Text, 0
                        Else
                            If colegio = "FLO001" And cmb_agno.Text = 2021 Then
                                ImprimeInformeFinalCab_tall_tri Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_mod_alu.Text
                            Else
                                ImprimeInformeFinalCab_tall Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_mod_alu.Text
                            End If
                        End If
'                    Else
'                        ImprimeInformeFinalCab Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_mod_alu.Text
                    End If
                    If lst_periodos.Text = "ANUAL" Then
                        If colegio = "SNB001" Then
                            PosImprInfFinal = ImprimeInformeFinal_tall_SBDO(Me.txt_rut_alu.Text, 0)
                            Call ImprimePieInformeFinal(PosImprInfFinal, modalidad, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_rut_alu.Text)
                            Printer.NewPage
                            ImprimeInformeFinalCab_tall_sumativa Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_mod_alu.Text, 1
                            PosImprInfFinal = ImprimeInformeFinal_tall_SBDO(Me.txt_rut_alu.Text, 1)
                        Else
                            If colegio = "FLO001" And cmb_agno.Text = 2021 Then
                                PosImprInfFinal = ImprimeInformeFinal_tall_tri(Me.txt_rut_alu.Text)
                            Else
                                PosImprInfFinal = ImprimeInformeFinal_tall(Me.txt_rut_alu.Text)
                            End If
                        End If
                        
                        
                    End If
                    If colegio = "FLO001" And cmb_agno.Text = 2021 Then
                        Call ImprimePieInformeFinal_tri(PosImprInfFinal, modalidad, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_rut_alu.Text)
                    Else
                        Call ImprimePieInformeFinal(PosImprInfFinal, modalidad, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_rut_alu.Text)
                    End If
            End If
        
        
            Me.Prgbar_Notas_curso.Max = asignaturas
            Me.Prgbar_Notas_total.MaxValue = asignaturas
            If Me.Opt_destino(1) Then
                '#############################################
                'Debo intervenir con salto si numperiodo="666"
                '#############################################
                If numperiodo = "666" Then GoTo LabelImprInfoFinal
                Call Imprimeencabezadopant
                coordenada = Imprimenotasalumnopant(Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo)
                Call imprimepiepant(coordenada, modalidad, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text)
                MsgBox ("Vista preliminar generada")
                PP1.ShowPreview
            Else
                '#############################################
                'Debo intervenir con salto si numperiodo="666"
                '#############################################
                If Not (numperiodo = "666") Then
                    Call imprimeencabezado
                    coordenada = Imprimenotasalumno(Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, modalidad, Me.txt_mod_alu.Text, numperiodo)
                    Call imprimepie(coordenada, modalidad, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text)
                Else
'LabelImprInfoFinal:
'                    Printer.Orientation = vbPRORLandscape
'                    If colegio = "PUD001" And lst_periodos.Text = "ANUAL" And Me.txt_nivel_alu.Text > 2 Then
'                        ImprimeInformeFinalCab_tall Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_mod_alu.Text
'                    Else
'                        ImprimeInformeFinalCab Me.txt_rut_alu.Text, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_mod_alu.Text
'                    End If
'                    If colegio = "PUD001" And lst_periodos.Text = "ANUAL" And Me.txt_nivel_alu.Text > 2 Then
'                        PosImprInfFinal = ImprimeInformeFinal_tall(Me.txt_rut_alu.Text)
'                    Else
'                        PosImprInfFinal = ImprimeInformeFinal(Me.txt_rut_alu.Text)
'                    End If
'                    Call ImprimePieInformeFinal(PosImprInfFinal, modalidad, Me.txt_nivel_alu.Text, Me.txt_letra_alu.Text, Me.txt_rut_alu.Text)
                End If
                Printer.EndDoc
                MsgBox ("Proceso de impresión OK")
            End If
            Me.Prgbar_Notas_curso.Value = 0
            Me.Prgbar_Notas_total.MaxValue = 0
            Me.Prgbar_Notas_total.ShowProgress 0
        Else
            MsgBox ("No se encontraron asignaturas asociadas al curso " & Me.txt_nivel_alu & " " & Me.txt_letra_alu.Text & " " & Me.txt_mod_alu.Text)
        End If
    Else
        MsgBox ("Faltan campos esenciales")
    End If
    
ElseIf Me.opt_indiv_gral(1) Then

    Dim condicion As String
    Dim Ngrado As String
    Dim letra As String
    Dim conteo As Integer
    
'    var_sql = "select valor from cfg where param = 'CODBC'"
'    objRS.Open var_sql, conn
'    colegio = objRS("valor")
'    objRS.Close
'
'    If colegio = "HUE001" And lst_periodos.Text = "ANUAL" Then
'                MsgBox "EL INFORME ANUAL SOLO PUEDE SER OBTENIDO A TRAVES DE LA PAGINA WEB", vbInformation
'                Exit Sub
'    End If

    ' aqui debo validar que hayan seleccionado todos los criterios
    a = Me.lst_cursosinf.SelCount
    
    If Me.lst_periodos.SelCount > 0 And Me.cmb_mod_notas.Text <> "" And Me.lst_cursosinf.SelCount > 0 And Me.cmb_fuentes.Text <> "" And Me.cmb_printers.Text <> "" Then
        Printer.FontName = Me.cmb_fuentes.Text
        If Me.opt_tipopapel(0).Value = True Then
            Printer.PaperSize = 1 ' 1 es Carta
        ElseIf Me.opt_tipopapel(1).Value = True Then
            Printer.PaperSize = 5 ' 1 Es Oficio
        End If
        
        '*********************** Informe Talleres ***********************
            numperiodo = aperiodos(Me.lst_periodos.ListIndex)
            var_sql = "select valor from cfg where param = 'CODBC'"
            objRS.Open var_sql, conn
            colegio = objRS("valor")
            objRS.Close
            If colegio = "HUE001" And lst_periodos.Text <> "ANUAL" Then
                Printer.PaperSize = 1
                
                    modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_mod_notas.Text & "'", conn)
                    condicion = ""
                    For conteo = 0 To Me.lst_cursosinf.ListCount - 1
                        If Me.lst_cursosinf.Selected(conteo) Then
                            Ngrado = Anuevocurso(conteo, 1)
                            letra = Anuevocurso(conteo, 2)
                            condicion = condicion & " and axc.num_gra = " & Ngrado & " and let_cur = '" & letra & "'"
                        End If
                    Next conteo
                    var_sql = "select axc.ci_alu,concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as 'nombre'" _
                                    & " from alu_x_cur axc,postulantes p" _
                                    & " where agno = " & cmb_agno.Text & " and axc.cod_ens = '" & modalidad & "'" _
                                    & " and activo_alu = 'SI'  and axc.ci_alu = p.ci_alu" & condicion
                    objRS.Open var_sql, conn

                    objRS.Close
                    For conteo = 0 To Me.lst_cursosinf.ListCount - 1 ' Esta sección es para
                        If Me.lst_cursosinf.Selected(conteo) Then
                            Ngrado = Anuevocurso(conteo, 1)
                            letra = Anuevocurso(conteo, 2)
                            var_sql = "select axc.ci_alu,concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as 'nombre'" _
                            & " from alu_x_cur axc,postulantes p" _
                            & " where agno = " & cmb_agno.Text & " and axc.cod_ens = '" & modalidad _
                            & "' and let_cur = '" & letra & "'" _
                            & " and activo_alu = 'SI' and axc.num_gra = " & Ngrado _
                            & " and axc.ci_alu = p.ci_alu"
                            objRS.Open var_sql, conn
                            
                            Prgbar_Notas_curso.Max = objRS.RecordCount '+ 1
                            Prgbar_Notas_curso.Min = 0
                            Prgbar_Notas_curso.Value = 0
                            
                            While Not objRS.EOF
                                cor = 0
                                Imprimeencabezadopant_hue
                                cor = Imprimenotasalumnopant_hue(CStr(objRS("ci_alu")), CStr(Ngrado), CStr(letra), CStr(modalidad), CStr(Me.txt_mod_alu.Text), CStr(numperiodo))
                                Call imprimepiepant_hue(CStr(objRS("ci_alu")), CInt(cor), CStr(modalidad), CStr(Ngrado), CStr(letra))
                                Printer.EndDoc
                                objRS.MoveNext
                                Prgbar_Notas_curso.Value = Prgbar_Notas_curso.Value + 1
                            Wend
                            objRS.Close
                        End If
                    Next conteo
                Exit Sub
            End If

        If colegio = "POD001" And lst_periodos.Text = "ANUAL" Then
                Printer.PaperSize = 1
                
                    modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_mod_notas.Text & "'", conn)
                    condicion = ""
                    For conteo = 0 To Me.lst_cursosinf.ListCount - 1
                        If Me.lst_cursosinf.Selected(conteo) Then
                            Ngrado = Anuevocurso(conteo, 1)
                            letra = Anuevocurso(conteo, 2)
                            condicion = condicion & " and axc.num_gra = " & Ngrado & " and let_cur = '" & letra & "'"
                        End If
                    Next conteo
                    var_sql = "select axc.ci_alu,concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as 'nombre'" _
                                    & " from alu_x_cur axc,postulantes p" _
                                    & " where agno = " & cmb_agno.Text & " and axc.cod_ens = '" & modalidad & "'" _
                                    & " and activo_alu = 'SI'  and axc.ci_alu = p.ci_alu" & condicion
                    objRS.Open var_sql, conn
                    Prgbar_Notas_curso.Max = objRS.RecordCount '+ 1
                    Prgbar_Notas_curso.Min = 0
                    objRS.Close
                    For conteo = 0 To Me.lst_cursosinf.ListCount - 1 ' Esta sección es para
                        If Me.lst_cursosinf.Selected(conteo) Then
                            Ngrado = Anuevocurso(conteo, 1)
                            letra = Anuevocurso(conteo, 2)
                            var_sql = "select des_ens from codigos_ensenanza where cod_ens = '" & modalidad & "'"
                            objRS.Open var_sql, conn
                            des_ens = objRS("des_ens")
                            objRS.Close
                            var_sql = "select axc.let_cur,axc.cod_ens,axc.num_gra,axc.ci_alu,concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as 'nombre'" _
                            & " from alu_x_cur axc,postulantes p" _
                            & " where agno = " & cmb_agno.Text & " and axc.cod_ens = '" & modalidad _
                            & "' and let_cur = '" & letra & "'" _
                            & " and activo_alu = 'SI' and axc.num_gra = " & Ngrado _
                            & " and axc.ci_alu = p.ci_alu"
                            objRS.Open var_sql, conn
                            While Not objRS.EOF
                                cor = 0
                                Printer.Orientation = vbPRORLandscape
     
                    If colegio = "PUD001" And lst_periodos.Text = "ANUAL" And objRS("num_gra") > 2 Then
                        ImprimeInformeFinalCab_tall objRS("ci_alu"), objRS("num_gra"), letra, des_ens
                    Else
                        ImprimeInformeFinalCab objRS("ci_alu"), objRS("num_gra"), letra, des_ens
                    End If
                    If colegio = "PUD001" And lst_periodos.Text = "ANUAL" And objRS("num_gra") > 2 Then
                        PosImprInfFinal = ImprimeInformeFinal_tall(objRS("ci_alu"))
                    Else
                        PosImprInfFinal = ImprimeInformeFinal(objRS("ci_alu"))
                    End If
                    Call ImprimePieInformeFinal(PosImprInfFinal, modalidad, objRS("num_gra"), objRS("let_cur"), objRS("ci_alu"))
                    
                                Printer.EndDoc
                                objRS.MoveNext
                                Prgbar_Notas_curso.Value = Prgbar_Notas_curso.Value + 1
                            Wend
                            objRS.Close
                        End If
                    Next conteo
                    MsgBox Prgbar_Notas_curso.Value
                Exit Sub
            End If

        numperiodo = aperiodos(Me.lst_periodos.ListIndex)
        Con = 0
        SelCursos = ""
        If Me.lst_cursosinf.SelCount > 0 Then
            modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_mod_notas.Text & "'", conn)
            For conteo = 0 To Me.lst_cursosinf.ListCount - 1 ' Esta sección es para
                asignaturas = 0
                If Me.lst_cursosinf.Selected(conteo) Then    ' contar alumnos.....
                    If Not (rsinforme.State = adStateClosed) Then
                        rsinforme.Close
                    End If
                    Ngrado = Anuevocurso(conteo, 1)
                    letra = Anuevocurso(conteo, 2)
                    rsinforme.CursorLocation = adUseClient
                    rsinforme.Open "select ci_alu from alu_x_cur where cod_ens = '" & modalidad & "' and num_gra = '" & Ngrado & "' and let_cur = '" & letra & "' and ucase(activo_alu) = 'SI' and agno = " & cmb_agno.Text, conn
                    totalalumnos = rsinforme.RecordCount
                    rsinforme.Close
                    asignaturas = CuentaReg("subsectores", "cod_ens = '" & modalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0", conn)

                    acumulado = acumulado + (totalalumnos * asignaturas)

                End If
            Next conteo
            avancebarratotal = 0
            Me.Prgbar_Notas_total.MaxValue = acumulado
            For indicecurso = 0 To Me.lst_cursosinf.ListCount - 1
                If Me.lst_cursosinf.Selected(indicecurso) Then
                    Me.Prgbar_Notas_curso.Value = 0 ' Vuelvo la barra de progreso curso a 0
                    Me.lst_cursosinf.ListIndex = indicecurso ' Aquí sitúo el cursor en el curso de la lista
                    Me.lst_cursosinf.Refresh
                    Ngrado = Anuevocurso(indicecurso, 1)
                    letra = Anuevocurso(indicecurso, 2)
                    Me.txt_cursoproceso.Text = ""
                    Me.txt_cursoproceso.Text = Ngrado & " " & letra
                    Me.txt_cursoproceso.Refresh
                    rsinforme.CursorLocation = adUseClient
                    rsinforme.Open "select ci_alu from alu_x_cur where agno=" & cmb_agno.Text & " and cod_ens = '" & modalidad & "' and num_gra = '" & Ngrado & "' and let_cur = '" & letra & "' and ucase(activo_alu) = 'SI'", conn
                    'Aquí acabo de buscar todos los alumnos activos de alu_x_cur
                    If rsinforme.RecordCount > 0 Then ' Si se encontraron alumnos activos en el curso
                        cuentaasignaturas = CuentaReg("subsectores", "cod_ens = '" & modalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0", conn)
                        ' acabo de contar las asignaturas del nivel y las multiplique por
                        ' la cantidad de alumnos.
                        ' Aquí acabo de darle el valor maximo a la barra notas
                        If cuentaasignaturas > 0 Then
                            Me.Prgbar_Notas_curso.Max = rsinforme.RecordCount * cuentaasignaturas
                            While Not rsinforme.EOF
                                ' Aquí debiera invoco el procedimiento de impresion de notas
                                ' de un alumno X
                                rutalumno = rsinforme("ci_alu")
                                
                                ' ################################################
                                ' # Aqui debo mandar a imprimir todos los informes
                                ' ################################################
                                If Not (numperiodo = "666") Then
'                                    Imprimeencabezadopant_tall
'                                    coordenada = Imprimenotasalumnopant_tall(rutalumno, Ngrado, letra, modalidad, Me.cmb_mod_notas.Text, numperiodo)
'                                    Call imprimepiepant_tall(coordenada, modalidad, Ngrado, letra)
                                      var_sql = "select valor from cfg where param = 'CODBC'"
                                      objRS.Open var_sql, conn
                                      colegio = objRS("valor")
                                      objRS.Close
                                      If colegio = "SNB001" Then
'                                        Imprimeencabezadopant_sanbe
'                                        coordenada = Imprimenotasalumnopant_sanbe(rutalumno, Ngrado, letra, modalidad, Me.cmb_mod_notas.Text, numperiodo)
'                                        Call imprimepiepant_tall(coordenada, modalidad, Ngrado, letra)
                                        If Ngrado < 7 And modalidad = "110" Then
                                            Imprimeencabezadopant_tall_formativa (0)
                                            cor = Imprimenotasalumnopant_tall_formativa(rutalumno, Ngrado, letra, modalidad, Me.cmb_mod_notas.Text, numperiodo, 0)
                                            Call imprimepiepant_tall(CInt(cor), modalidad, Ngrado, letra)
                                            Printer.NewPage
                                            Imprimeencabezadopant_tall_formativa (1)
                                            cor = Imprimenotasalumnopant_tall_formativa(rutalumno, Ngrado, letra, modalidad, Me.cmb_mod_notas.Text, numperiodo, 1)
                                            Call imprimepiepant_tall(CInt(cor), modalidad, Ngrado, letra)
                                        Else
                                            Imprimeencabezadopant_sanbe (0)
                                            cor = Imprimenotasalumnopant_sanbe(rutalumno, Ngrado, letra, modalidad, Me.cmb_mod_notas.Text, numperiodo, 0)
                                            Call imprimepiepant_tall(CInt(cor), modalidad, Ngrado, letra)
                                            Printer.NewPage
                                            Imprimeencabezadopant_sanbe (1)
                                            cor = Imprimenotasalumnopant_sanbe(rutalumno, Ngrado, letra, modalidad, Me.cmb_mod_notas.Text, numperiodo, 1)
                                            Call imprimepiepant_tall(CInt(cor), modalidad, Ngrado, letra)
                                        End If
                                      Else
                                        Imprimeencabezadopant_tall
                                        coordenada = Imprimenotasalumnopant_tall(rutalumno, Ngrado, letra, modalidad, Me.cmb_mod_notas.Text, numperiodo)
                                        Call imprimepiepant_tall(coordenada, modalidad, Ngrado, letra)
                                      End If
                                Else
                                    Printer.Orientation = vbPRORLandscape
                                    If colegio = "SNB001" Then
                                        ImprimeInformeFinalCab_tall_sumativa rutalumno, Ngrado, letra, Me.cmb_mod_notas.Text, 0
                                    Else
                                        If colegio = "FLO001" And cmb_agno.Text = 2021 Then
                                            ImprimeInformeFinalCab_tall_tri rutalumno, Ngrado, letra, Me.cmb_mod_notas.Text
                                        Else
                                            ImprimeInformeFinalCab_tall rutalumno, Ngrado, letra, Me.cmb_mod_notas.Text
                                        End If
                                    End If
                          '''''     PosImprInfFinal = ImprimeInformeFinal(rutalumno)
                                    If colegio = "SNB001" Then
                                        PosImprInfFinal = ImprimeInformeFinal_tall_SBDO(rutalumno, 0)
                                        Call ImprimePieInformeFinal(PosImprInfFinal, modalidad, Ngrado, letra, rutalumno)
                                        Printer.NewPage
                                        ImprimeInformeFinalCab_tall_sumativa rutalumno, Ngrado, letra, Me.cmb_mod_notas.Text, 1
                                        PosImprInfFinal = ImprimeInformeFinal_tall_SBDO(rutalumno, 1)
                                    Else
                                        If colegio = "FLO001" And cmb_agno.Text = 2021 Then
                                            PosImprInfFinal = ImprimeInformeFinal_tall_tri(rutalumno)
                                        Else
                                            PosImprInfFinal = ImprimeInformeFinal_tall(rutalumno)
                                        End If
                                    End If
                                    If colegio = "FLO001" And cmb_agno.Text = 2021 Then
                                        Call ImprimePieInformeFinal_tri(PosImprInfFinal, modalidad, Ngrado, letra, rutalumno)
                                    Else
                                        Call ImprimePieInformeFinal(PosImprInfFinal, modalidad, Ngrado, letra, rutalumno)
                                    End If
                                End If
                                Me.txt_paginas.Text = Printer.Page
                                Printer.NewPage
                                rsinforme.MoveNext
                            Wend
                        Else
                            MsgBox ("No se encontraron asignaturas asociadas al curso " & Ngrado & " " & letra & " " & Me.cmb_mod_notas.Text)
                        End If
                    Else
                        MsgBox ("No se encontraron alumnos en el curso " & Ngrado & " " & letra & " " & Me.cmb_mod_notas.Text)
                    End If
                    Me.lst_cursosinf.Selected(indicecurso) = False
                    Me.lst_cursosinf.Refresh
                    rsinforme.Close
                        
                End If
            Next indicecurso
            Printer.EndDoc
            MsgBox ("Proceso OK")
            Me.Prgbar_Notas_curso.Value = 0
            Me.Prgbar_Notas_total.ShowProgress 0
        End If
    Else
        MsgBox ("Faltan campos esenciales")
    End If
End If


Exit Sub
'Errorimpresion:
'If Err.Number = 482 Then MsgBox "Hubo un problema al imprimir."
'If Err.Number = 380 Then
'    If Me.Opt_destino(0) Then
'        MsgBox "Error en los parámetros de impresión" & Chr(13) & "La impresora no es compatible con el tipo del papel." & Chr(13) & "Seleccione otra impresora."
'    Else
'        MsgBox "No es posible generar la vista preliminar con el tipo de letra seleccionado" & Chr(13) & "Seleccione otro tipo."
'    End If
'Else
'    MsgBox (Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source)
'    Resume
'End If
End Sub

Private Sub btn_otro_alu_Click()
Me.txt_nom_alu.Text = ""
Me.txt_rut_alu.Text = ""
Me.txt_nivel_alu.Text = ""
Me.txt_letra_alu.Text = ""
Me.txt_mod_alu.Text = ""
Me.txt_apo_alu.Text = ""
Me.txt_estado_alu.Text = ""
Me.txt_nom_alu.Enabled = True
Me.txt_nom_alu.SetFocus
Me.btn_otro_alu.Enabled = False
Busqueda = 1
End Sub

Private Sub btn_rep_cursos_Click()
Dim Ngrado As String
Dim letra As String
Dim SelCursos As String
Dim modalidad As String
Dim Con As Integer
Con = 0
SelCursos = ""
If Me.lst_cursos.SelCount > 0 And Me.cmb_modalidad.Text <> "" Then
    modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_modalidad.Text & "'", conn)
    For t = 0 To Me.lst_cursos.ListCount - 1
        If Me.lst_cursos.Selected(t) Then
            Con = t
        End If
    Next t
    For t = 0 To Me.lst_cursos.ListCount - 1
        If Me.lst_cursos.Selected(t) Then
            Ngrado = Anuevocurso(t, 1)
            letra = Anuevocurso(t, 2)
            If t = Con Then
                SelCursos = SelCursos & "({alu_x_cur.num_gra}  = '" & Ngrado & "' and {alu_x_cur.let_cur} = '" & letra & "' and {alu_x_cur.cod_ens} ='" & modalidad & "')"
            Else
                SelCursos = SelCursos & "({alu_x_cur.num_gra}  = '" & Ngrado & "' and {alu_x_cur.let_cur} = '" & letra & "' and {alu_x_cur.cod_ens} ='" & modalidad & "')" & " or "
            End If
        End If
    Next
    SelCursos = "(" & SelCursos & ") AND {alu_x_cur.agno} = " & Combo_agno_cartola.Text & " AND {matriculas.confirmado}='SI'"
    
    rs.CursorLocation = adUseClient
    rs.Open "select nom_est, dir_est, localidad_est from establecimientos", conn
    If rs.RecordCount > 0 Then
        Nombrecol = rs("Nom_est")
        Direccol = rs("Dir_est")
        ComunaCol = rs("Localidad_est")
    End If
    rs.Close
    '******** CAMBIAR EL TITULO DEL INFORME ********'
    If MenuInformes = "cartola_rifa_ent" Then
        titulo = "CARTOLA DE CURSO: Entrega de Rifas"
       Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\cartola_rifa.rpt"
    Else
        If MenuInformes = "cartola_rifa_rec" Then
            titulo = "CARTOLA DE CURSO: Recepcion de Rifas"
            Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\cartola_recep_rifa.rpt"
        Else
            If MenuInformes = "cartola" Then
                titulo = "CARTOLA DE CURSO"
                If Me.Chk_Rut.Value = 1 Then
                    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\cartolarut.rpt"
                Else
                    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\cartolacurso.rpt"
                End If
            Else
            If MenuInformes = "revision" Then
                titulo = "DATOS PARA REVISIÓN DE CUPONERAS"
                Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\Revicup.rpt"
            End If
            End If
        End If
    End If
    
    Form_main.CrystalReport.Formulas(0) = "nombrecolegio = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "direccioncolegio = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacolegio = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "titulo= '" & titulo & "'"
    Form_main.CrystalReport.Formulas(4) = "hora = '" & Time & "'"
    Form_main.CrystalReport.Formulas(5) = "anhoescolar = '" & Combo_agno_cartola.Text & "'"
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.ReplaceSelectionFormula (SelCursos)
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.Action = 1
    
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
Else
    MsgBox ("Faltan opciones por seleccionar")
End If

End Sub

Private Sub btn_rep_emat_Click()

If Me.cmb_mod_emat.Text <> "" And Me.cmb_jor_emat.Text <> "" _
And Me.lst_emat.SelCount > 0 And Me.cmb_mes_emat.Text <> "" Then
    Call CreaBD(DirAplicacion & "\GesTemp.mdb")
    'Aquí uso la variable rendim para no declarar otra.....
    'Set Rendim = DBEngine.Workspaces(0).OpenDatabase(DirAplicacion & "\GesTemp.mdb")
    Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Detalles", "20,10")
    Call GeneraEstadMat
Else
    MsgBox ("Faltan opciones por selecionar")
End If

End Sub

Private Sub btn_rep_regmatriculas_Click()
Dim Fecha As Date
Dim fechainicio As String
Dim fechafin As String
   Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)

    'On Error GoTo eRR
    If MenuInformes = "registromatriculas" Then
        If Me.cmb_mod_reg.Text <> "" And Me.dtp_reg_matriculas.Value <> "" Then
            'fechainicio = Anno & "-01-01"
            Fecha = Format(Me.dtp_reg_matriculas.Value, "yyyy-mm-dd")
            fechainicio = Trim(Combo_Agno_RegMat.Text) & ",01,01"
            fechafin = Year(Fecha) & "," & Month(Fecha) & "," & Day(Fecha)
            rs.CursorLocation = adUseClient
            rs.Open "select nom_dir_sub,ape_pat_dir_sub,ape_mat_dir_sub,nom_sostenedor, rut_sostenedor, rut_est, nom_est, dir_est, localidad_est, rut_director_est, nom_dir, ape_pat_dir, ape_mat_dir, Rut_Rep_legal, Nom_Rep_legal, ape_pat_rep_legal, ape_mat_rep_legal, dec_coop, fec_dec_coop from establecimientos", conn
            If rs.RecordCount > 0 Then
                rutcol = rs("rut_est")
                Nombrecol = rs("Nom_est")
                Direccol = rs("Dir_est")
                ComunaCol = rs("Localidad_est")
                nomreplegal = rs("Nom_rep_legal") & " " & rs("ape_pat_rep_legal") & " " & rs("ape_mat_rep_legal")
                rutreplegal = rs("Rut_Rep_legal")
                rutdir = rs("rut_director_est")
                
                If cole = "PUD001" Then
                    nomdir = rs("Nom_dir_sub") & " " & rs("ape_pat_dir_sub") & " " & rs("ape_mat_dir_sub")
                Else
                    nomdir = rs("Nom_dir") & " " & rs("ape_pat_dir") & " " & rs("ape_mat_dir")
                End If
                deccoop = rs("dec_coop")
                fechadecoop = rs("fec_dec_coop")
                nomsost = rs("nom_sostenedor")
                rutsost = rs("rut_sostenedor")
            End If
            rs.Close
            titulo = "REGISTRO DE MATRÍCULAS " & UCase(Me.cmb_mod_reg)
            Codens = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_mod_reg.Text & "'", conn) 'agregar los dos codigos de prekinder y parvularia
'            If Codens = "996" Then Codens = "010"

            total = DevuelveCampo("matriculas", "", "COUNT(*) total", "anno_mat = " & Year(Fecha) & " AND (ens = '" & Codens & "' OR ens = '" & Codens & "') AND num_mat <> '00000' and fec_mat <= '" & Format(Me.dtp_reg_matriculas.Value, "yyyy-mm-dd") & "'", conn)
            bajas = DevuelveCampo("matriculas", "", "COUNT(*) total", "anno_mat = " & Year(Fecha) & " AND fec_retiro <> '1111-11-11' AND (cod_ens = '" & Ens & "' OR ens = '" & Codens & "') AND num_mat <> '00000' and fec_retiro <= '" & Format(Me.dtp_reg_matriculas.Value, "yyyy-mm-dd") & "'", conn)
            total_actual = (total - bajas)
            
            '''' Modificamos para que se reflejen las altas en el registro de matricula
            var_sql = "update alu_x_cur set ens = cod_ens,gra = num_gra,pre = num_gra where (cod_ens = '010' or cod_ens = '110' or cod_ens = '310') and agno = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update matriculas set ens = cod_ens,gra = num_gra,pre = num_gra where (cod_ens = '010' or cod_ens = '110' or cod_ens = '310') and anno_mat = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update alu_x_cur set ens = '010' where cod_ens = '996' and agno = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update matriculas set ens = '010' where cod_ens = '996' and anno_mat = " & Anno & ";"
            conn.Execute var_sql

            var_sql = "update alu_x_cur set ens = '111' where cod_ens = '111' and agno = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update matriculas set ens = '111' where cod_ens = '111' and anno_mat = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update matriculas set gra = 3,pre = 'PG' where cod_ens = '111' and anno_mat = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update alu_x_cur set gra = 3,pre = 'PG' where cod_ens = '111' and agno = " & Anno & ";"
            conn.Execute var_sql

            var_sql = "update matriculas set gra = 4,pre = 'PK' where cod_ens = '996' and anno_mat = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update matriculas set gra = 5,pre = 'K' where cod_ens = '010' and anno_mat = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update alu_x_cur set gra = 4,pre = 'PK' where cod_ens = '996' and agno = " & Anno & ";"
            conn.Execute var_sql
            var_sql = "update alu_x_cur set gra = 5,pre = 'K' where cod_ens = '010' and agno = " & Anno & ";"
            conn.Execute var_sql
            
                       
            
                       'realizamos actualizacion de datos de nombre de papa y mama antes de imprimir
            'se modifico 12-05-2022
            var_sql = ""
            var_sql = var_sql & " UPDATE  POSTULANTES P, APODERADOS A"
            var_sql = var_sql & " SET P.NOM_PAD_ALU =  CONCAT(A.APE1_APO, ' ',  A.APE2_APO, ' ', A.NOMS_APO)"
            var_sql = var_sql & " Where p.RUT_PAD_ALU = a.rut_apo"
            conn.Execute var_sql

            var_sql = ""
            var_sql = var_sql & " UPDATE  POSTULANTES P, APODERADOS A"
            var_sql = var_sql & " SET P.NOM_MAD_ALU =  CONCAT(A.APE1_APO, ' ',  A.APE2_APO, ' ', A.NOMS_APO)"
            var_sql = var_sql & " Where p.RUT_MAD_ALU = a.rut_apo"
            conn.Execute var_sql
            
            Form_main.CrystalReport.Formulas(0) = "nombrecolegio = '" & Nombrecol & "'"
            Form_main.CrystalReport.Formulas(1) = "direccioncolegio = '" & Direccol & "'"
            Form_main.CrystalReport.Formulas(2) = "comunacolegio = '" & ComunaCol & "'"
            Form_main.CrystalReport.Formulas(3) = "hora = '" & Time & "'"
            Form_main.CrystalReport.Formulas(4) = "nomreprelegal = '" & nomreplegal & "'"
            Form_main.CrystalReport.Formulas(5) = "rutreprelegal = '" & rutreplegal & "'"
            Form_main.CrystalReport.Formulas(6) = "nomsost = '" & nomsost & "'"
            Form_main.CrystalReport.Formulas(7) = "rutsost = '" & rutsost & "'"
            Form_main.CrystalReport.Formulas(8) = "rutdirec = '" & rutdir & "'"
            Form_main.CrystalReport.Formulas(9) = "nomdirec = '" & nomdir & "'"
            Form_main.CrystalReport.Formulas(10) = "DecCooper = '" & deccoop & "'"
            Form_main.CrystalReport.Formulas(11) = "FecDecCooper = '" & fechadecoop & "'"
            Form_main.CrystalReport.Formulas(12) = "TITULO = '" & titulo & "'"
            Form_main.CrystalReport.Formulas(13) = "total = '" & total & "'"
            Form_main.CrystalReport.Formulas(14) = "bajas = '" & bajas & "'"
            Form_main.CrystalReport.Formulas(15) = "total_actual = '" & total_actual & "'"
'            If cole = "PUD001" Then
'                Form_main.CrystalReport.Formulas(16) = "dir_sub = '" & "DIRECTORA SUBROGANTE" & "'"
'            Else
'                Form_main.CrystalReport.Formulas(16) = "dir_sub = '" & "DIRECTOR(A)" & "'"
'            End If
'
'            Form_main.CrystalReport.Formulas = ""
            Form_main.CrystalReport.WindowTitle = "Registro de Matrículas"
            
            var_sql = "SELECT nombre,colegio" _
                    & " From hist_cod_colegio" _
                    & " where colegio = (select valor from cfg where param = 'codbc')"
            objRS.Open var_sql, conn
            colegio = objRS("colegio")
            nombre = objRS("nombre")
            objRS.Close
            
'            If colegio = "LIN001" Then
'                Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\regmatricula_lincoln.rpt"
'            Else
'                Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\regmatricula.rpt"
'            End If
            
            
'            If colegio = "LIN001" Or colegio = "LON001" Then
'                Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\regmatricula_anexo.rpt"
'            Else
'                Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\regmatricula.rpt"
'            End If

            If colegio = "LIN001" Then
                Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\regmatricula_lin.rpt"
            Else
                If colegio = "LON001" Then
                'Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\regmatricula_anexo.rpt"
                Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\regmatricula.rpt"
                Else
                Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\regmatricula.rpt"
                End If
            End If
            
            
            Form_main.CrystalReport.ReplaceSelectionFormula ("")  ' agegar los dos codigos
            Form_main.CrystalReport.ReplaceSelectionFormula ("{alu_x_cur.ens}= '" & Codens & "' and {matriculas.ANNO_MAT} = '" & Trim(Combo_Agno_RegMat.Text) & "' and {matriculas.FEC_MAT} <= '" & Format(fechafin, "yyyy-mm-dd") & "' and {alu_x_cur.agno}=" & Combo_Agno_RegMat.Text & " and {matriculas.CONFIRMADO} = 'SI'")
            Form_main.CrystalReport.WindowState = crptMaximized
            Form_main.CrystalReport.Action = 1
            Form_main.CrystalReport.ReplaceSelectionFormula ("")
            Call LimpiaFormulas(Form_main.CrystalReport, 30)
        Else
            MsgBox ("Faltan opciones por seleccionar")
        End If
        
    End If

End Sub

Private Sub chk_todos_cursos_Click()
If Me.chk_todos_cursos.Value Then
    For t = 0 To Me.lst_cursos.ListCount - 1
        Me.lst_cursos.Selected(t) = True
    Next t
Else
    For t = 0 To Me.lst_cursos.ListCount - 1
        Me.lst_cursos.Selected(t) = False
        Me.lst_cursos.ListIndex = 0
    Next t
End If
End Sub

Private Sub chk_todos_emat_Click()

If Me.chk_todos_emat.Value Then
    For t = 0 To Me.lst_emat.ListCount - 1
        Me.lst_emat.Selected(t) = True
    Next t
Else
    For t = 0 To Me.lst_emat.ListCount - 1
        Me.lst_emat.Selected(t) = False
        Me.lst_emat.ListIndex = 0
    Next t
End If
End Sub

Private Sub chk_todos_notas_Click()
If Me.chk_todos_notas.Value Then
    For t = 0 To Me.lst_cursosinf.ListCount - 1
        Me.lst_cursosinf.Selected(t) = True
    Next t
Else
    For t = 0 To Me.lst_cursosinf.ListCount - 1
        Me.lst_cursosinf.Selected(t) = False
        Me.lst_cursosinf.ListIndex = 0
    Next t
End If
End Sub

Private Sub cmb_agno_Click()
    If (opt_indiv_gral(0).Value) And (lst_nom_alu.ListCount > 0) Then
        lst_nom_alu_DblClick
    End If
End Sub

Private Sub cmb_fuentes_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_jor_emat_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_mes_emat_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub Cmb_Mes_fin_Click()
    
    Me.Btn_gen_reportes.Enabled = True
    Me.Btn_gen_reportes.SetFocus

End Sub

Private Sub Cmb_Mes_fin_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Len(Me.Cmb_Mes_fin.Text) <> 0 Then
    Me.Btn_gen_reportes.Enabled = True
    Me.Btn_gen_reportes.SetFocus
End If
End Sub

Private Sub Cmb_Mes_ini_Click()
Me.Cmb_Mes_fin.Clear
MesINI = Me.Cmb_Mes_ini.ListIndex + 1
For t = MesINI To 12
    Me.Cmb_Mes_fin.AddItem ameses(t, 1)
Next t
Me.Cmb_Mes_fin.Enabled = True


End Sub

Private Sub Cmb_Mes_ini_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Len(Me.Cmb_Mes_ini.Text) <> 0 Then
    Me.Cmb_Mes_fin.Enabled = True
    Me.Cmb_Mes_fin.SetFocus
End If
End Sub

Private Sub cmb_mod_cambiocurso_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_mod_emat_Click()
Me.chk_todos_emat.Enabled = True
Me.chk_todos_emat.Value = 0

contador = contador + 1

If Me.cmb_mod_emat.Text = "Todas" Then
       If contador = 1 Then
           nivel = "Otros Tipos (Pre Kinder)"
       End If
       If contador = 2 Then
           nivel = "Educación Parvularia"
       End If
       If contador = 3 Then
           nivel = "Educación General Básica"
       End If
       If contador = 4 Then
           nivel = "Educación General Básica"
       End If
       
    modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & nivel & "'", conn) 'saca codigo enseñanza por nombre

Else

    modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_mod_emat.Text & "'", conn) 'saca codigo enseñanza por nombre
End If

CodDes = DevuelveCampo("codigos_ensenanza", "", "cod_des", "des_ens = '" & Me.cmb_mod_emat.Text & "'", conn)
rs.CursorLocation = adUseClient

If Me.cmb_mod_emat.Text <> "Todas" Then
    rs.Open "SELECT distinct num_gra FROM cursos where cod_ens ='" & modalidad & "' and agno='" & Trim(Cmb_AgnoEstadMat) & "'", conn

    If rs.RecordCount > 0 Then
    Me.lst_emat.Clear
    While Not rs.EOF
        Me.lst_emat.AddItem rs("num_gra")
        rs.MoveNext
    Wend
    End If

Else
    'rs.Open "SELECT distinct num_gra FROM cursos where cod_ens ='966' or cod_ens ='010' or cod_ens ='110' or cod_ens ='310' and agno='" & Trim(Cmb_AgnoEstadMat) & "'", conn
    rs.Open "SELECT distinct num_gra FROM cursos where cod_ens ='" & modalidad & "' and agno='" & Trim(Cmb_AgnoEstadMat) & "'", conn
    
    Me.cmb_jor_emat = "Todas"
    Me.cmb_jor_emat.Enabled = False
    Me.Cmb_AgnoEstadMat.Enabled = False
    Me.cmb_mod_emat.Enabled = False
    Me.masivo_limpiar.Visible = True
    Me.chk_todos_emat.Value = 1
    Me.chk_todos_emat.Enabled = False
    Me.lst_emat.Enabled = False

If rs.RecordCount > 0 Then
    Me.lst_emat.Clear
    While Not rs.EOF
        Me.lst_emat.AddItem rs("num_gra")
        rs.MoveNext
    Wend
End If

    Call chk_todos_emat_Click

End If
rs.Close
End Sub

Private Sub cmb_mod_emat_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_mod_notas_Click()

If val(cmb_agno.Text) = 0 Then
    MsgBox "No se ha indicado el año a seleccionar.", vbExclamation, "Falta Información"
    cmb_mod_notas.Text = ""
    cmb_agno.SetFocus
    Exit Sub
End If
If lst_periodos.ListIndex = -1 Then
    MsgBox "Debe seleccionar un periodo.", vbExclamation, "Falta Información"
    cmb_mod_notas.Text = ""
    lst_periodos.SetFocus
    Exit Sub
End If
Me.chk_todos_notas.Enabled = True
modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_mod_notas.Text & "'", conn)
rs.CursorLocation = adUseClient
rs.Open "SELECT num_gra, let_cur FROM CURSOS where agno=" & cmb_agno.Text & " and cod_ens ='" & modalidad & "' ORDER BY NUM_GRA,let_cur", conn
If rs.RecordCount > 0 Then
    ReDim Anuevocurso(rs.RecordCount, 2)
    Me.lst_cursosinf.Clear
    c = 0
    While Not rs.EOF
        lst_cursosinf.AddItem rs("num_gra") + " " + rs("LET_CUR")
        Anuevocurso(c, 1) = rs("num_gra")
        Anuevocurso(c, 2) = rs("let_cur")
        rs.MoveNext
        c = c + 1
    Wend
    End If
rs.Close

End Sub

Private Sub cmb_mod_notas_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
'*********************************
'***** LLENADO DE LA LISTA *******
'*********************************
Private Sub cmb_modalidad_Click()
modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_modalidad.Text & "'", conn)
rs.CursorLocation = adUseClient
rs.Open "SELECT num_gra, let_cur FROM CURSOS where cod_ens ='" & modalidad & "' AND AGNO=" & Combo_agno_cartola.Text & " ORDER BY NUM_GRA,let_cur", conn
If rs.RecordCount > 0 Then
    ReDim Anuevocurso(rs.RecordCount, 2)
    Me.lst_cursos.Clear
    Me.chk_todos_cursos.Value = 0
    c = 0
    While Not rs.EOF
        lst_cursos.AddItem rs("num_gra") + " " + rs("LET_CUR")
        Anuevocurso(c, 1) = rs("num_gra")
        Anuevocurso(c, 2) = rs("let_cur")
        rs.MoveNext
        c = c + 1
    Wend
    End If
rs.Close

End Sub

Private Sub cmb_modalidad_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub Command1_Click()

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub cmb_printers_Click()
Dim X As Printer
Dim Sw_Arial As Boolean

I = 0
For Each X In Printers
   If I = Me.cmb_printers.ListIndex Then
      ' La define como predeterminada del sistema.
      Set Printer = X
      ' Sale del bucle.
      Exit For
   End If
    I = I + 1
Next
Me.cmb_fuentes.Clear
Sw_Arial = False

For t = 0 To Printer.FontCount - 1
    Me.cmb_fuentes.AddItem Printer.Fonts(t)
    If Printer.Fonts(t) = "Arial" Then
        Sw_Arial = True
    End If
Next t

If Sw_Arial Then
    Me.cmb_fuentes.Text = "Arial"
End If
End Sub

Private Sub Command3_Click()

End Sub

Private Sub cmb_printers_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub Combo_agno_cartola_Click()
    cmb_modalidad_Click
End Sub


Private Sub Combo_Agno_RegMat_Click()
    If Year(dtp_reg_matriculas.MinDate) > val(Combo_Agno_RegMat.Text) Then
        dtp_reg_matriculas.MinDate = "01-01-" & Combo_Agno_RegMat.Text
        dtp_reg_matriculas.MaxDate = "31-12-" & Combo_Agno_RegMat.Text
    Else
        dtp_reg_matriculas.MaxDate = "31-12-" & Combo_Agno_RegMat.Text
        dtp_reg_matriculas.MinDate = "01-01-" & Combo_Agno_RegMat.Text
    End If
End Sub



Private Sub Form_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub Form_Load()
contador = 0

Dim rs1 As ADODB.Recordset
Set rs1 = New ADODB.Recordset

If MenuInformes = "registroaltas" Or MenuInformes = "registrobajas" Or MenuInformes = "cambiocurso" Then
    Set rs = New ADODB.Recordset
    If MenuInformes = "cambiocurso" Then
        Me.Frame_Fechas.Caption = "Registro de Cambios de curso"
    ElseIf MenuInformes = "registroaltas" Then
        Me.Frame_Fechas.Caption = "Registro de Altas"
    ElseIf MenuInformes = "registrobajas" Then
        Me.Frame_Fechas.Caption = "Registro de Bajas"
    End If
    Call LlenaCombo(cmb_mod_cambiocurso, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
    Call Form_main.hideframeimpresion
    Me.Height = 2700
    Me.Width = 6700
    Me.Frame_Fechas.Top = 120
    Me.Frame_Fechas.Left = 120
    Me.Frame_Fechas.Visible = True
    CentrarForma Me
    Me.Show
    Me.Cmb_Mes_fin.Enabled = False
    Me.opt_destino_registros(0).Value = True
    Me.Btn_gen_reportes.Enabled = True
    ameses(1, 1) = "Enero"
    ameses(1, 2) = "01,01"
    ameses(1, 3) = "01,31"
    ameses(2, 1) = "Febrero"
    ameses(2, 2) = "02,01"
    ameses(2, 3) = "02,28"
    ameses(3, 1) = "Marzo"
    ameses(3, 2) = "03,01"
    ameses(3, 3) = "03,31"
    ameses(4, 1) = "Abril"
    ameses(4, 2) = "04,01"
    ameses(4, 3) = "04,30"
    ameses(5, 1) = "Mayo"
    ameses(5, 2) = "05,01"
    ameses(5, 3) = "05,31"
    ameses(6, 1) = "Junio"
    ameses(6, 2) = "06,01"
    ameses(6, 3) = "06,30"
    ameses(7, 1) = "Julio"
    ameses(7, 2) = "07,01"
    ameses(7, 3) = "07,31"
    ameses(8, 1) = "Agosto"
    ameses(8, 2) = "08,01"
    ameses(8, 3) = "08,31"
    ameses(9, 1) = "Septiembre"
    ameses(9, 2) = "09,01"
    ameses(9, 3) = "09,30"
    ameses(10, 1) = "Octubre"
    ameses(10, 2) = "10,01"
    ameses(10, 3) = "10,31"
    ameses(11, 1) = "Noviembre"
    ameses(11, 2) = "11,01"
    ameses(11, 3) = "11,30"
    ameses(12, 1) = "Diciembre"
    ameses(12, 2) = "12,01"
    ameses(12, 3) = "12,31"
    For t = 1 To 12
        Me.Cmb_Mes_ini.AddItem ameses(t, 1)
    Next t

ElseIf MenuInformes = "registromatriculas" Then
    Set rs = New ADODB.Recordset
    Call Form_main.hideframeimpresion
    Me.Height = 2750
    Me.Width = 6595
    Me.frame_reg_matriculas.Top = 120
    Me.frame_reg_matriculas.Left = 120
    Me.frame_reg_matriculas.Visible = True
    Call LlenaCombo(cmb_mod_reg, "codigos_ensenanza", "des_ens", " where cod_ens <> '996' order by ord_ens", conn)
    For I = 2005 To IIf((Year(Date) > 2005), Year(Date), 2005)
        Combo_Agno_RegMat.AddItem str(I)
    Next I
    Combo_Agno_RegMat.Text = Anno
    Me.dtp_reg_matriculas.MinDate = "01/01/" & Combo_Agno_RegMat.Text
    Me.dtp_reg_matriculas.MaxDate = "31/12/" & Combo_Agno_RegMat.Text
    Me.Opt_dest_reg(0).Value = True
    CentrarForma Me
    'Me.Show
    '**** PARA ELEGIR EL TITULO ***********'
ElseIf MenuInformes = "cartola" Or MenuInformes = "revision" Or MenuInformes = "cartola_rifa_ent" Or MenuInformes = "cartola_rifa_rec" Then
    If MenuInformes = "cartola" Then Me.Caption = "Cartolas de Cursos"
    '**** INF RIFAS ****'
    If MenuInformes = "cartola_rifa_ent" Then Me.Caption = "Cartolas de Cursos: Entrega de Rifas"
    If MenuInformes = "cartola_rifa_rec" Then Me.Caption = "Cartolas de Cursos: Recepcion de Rifas"
    '***************
    If MenuInformes = "revision" Then Me.Caption = "Datos para revisión Cuponeras"
    Set rs = New ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    Call Form_main.hideframeimpresion
    Me.Height = 3680
    Me.Width = 5600
    Me.Frame_Cursos.Top = 120
    Me.Frame_Cursos.Left = 120
    Me.Frame_Cursos.Visible = True
    If MenuInformes = "cartola_rifa_ent" Then
       Me.Chk_Rut.Visible = False
    End If
    If MenuInformes = "cartola_rifa_rec" Then
        Me.Chk_Rut.Visible = False
    End If
    Call LlenaCombo(cmb_modalidad, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
    Me.opt_destino_cartola(0).Value = True
    
    For I = 2005 To IIf((Year(Date) > 2005), Year(Date), 2005)
        Combo_agno_cartola.AddItem str(I)
    Next I
    Combo_agno_cartola.Text = Anno
    
    CentrarForma Me
ElseIf MenuInformes = "vacantes" Then
    Set rs = New ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    Call Form_main.hideframeimpresion
    Me.Caption = "Proyección de Vacantes"
    Me.Height = 2150
    Me.Width = 4615
    Me.Frame_Vacantes.Top = 120
    Me.Frame_Vacantes.Left = 120
    Me.Frame_Vacantes.Visible = True
    Me.Opt_vacantes(0).Value = True
    CentrarForma Me
ElseIf MenuInformes = "Estadmat" Then
    Set rs = New ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    
    Call LlenaCombo(cmb_mod_emat, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
    If Me.cmb_mod_emat.ListCount > 0 Then Me.cmb_mod_emat.AddItem "Todas"
    
    Call LlenaCombo(cmb_jor_emat, "jornadas", "des_jor", "", conn)
    If Me.cmb_jor_emat.ListCount > 0 Then Me.cmb_jor_emat.AddItem "Todas"
    Call Form_main.hideframeimpresion
    Me.Height = 3170
    Me.Width = 6700
    Me.frame_estad_mat.Top = 120
    Me.frame_estad_mat.Left = 120
    Me.frame_estad_mat.Visible = True
    CentrarForma Me
    Me.Show
    Me.opt_destino_emat(0).Value = True
    Me.btn_rep_emat.Enabled = True
    ameses(1, 1) = "Enero"
    ameses(1, 2) = "01/01"
    ameses(1, 3) = "01/31"
    ameses(2, 1) = "Febrero"
    ameses(2, 2) = "02/01"
    ameses(2, 3) = "02/28"
    ameses(3, 1) = "Marzo"
    ameses(3, 2) = "03/01"
    ameses(3, 3) = "03/31"
    ameses(4, 1) = "Abril"
    ameses(4, 2) = "04/01"
    ameses(4, 3) = "04/30"
    ameses(5, 1) = "Mayo"
    ameses(5, 2) = "05/01"
    ameses(5, 3) = "05/31"
    ameses(6, 1) = "Junio"
    ameses(6, 2) = "06/01"
    ameses(6, 3) = "06/30"
    ameses(7, 1) = "Julio"
    ameses(7, 2) = "07/01"
    ameses(7, 3) = "07/31"
    ameses(8, 1) = "Agosto"
    ameses(8, 2) = "08/01"
    ameses(8, 3) = "08/01"
    ameses(9, 1) = "Septiembre"
    ameses(9, 2) = "09/01"
    ameses(9, 3) = "09/30"
    ameses(10, 1) = "Octubre"
    ameses(10, 2) = "10/01"
    ameses(10, 3) = "10/31"
    ameses(11, 1) = "Noviembre"
    ameses(11, 2) = "11/01"
    ameses(11, 3) = "11/30"
    ameses(12, 1) = "Diciembre"
    ameses(12, 2) = "12/01"
    ameses(12, 3) = "12/31"
    For t = 1 To 12
        Me.cmb_mes_emat.AddItem ameses(t, 1)
    Next t
    
    For I = 2005 To Anno
        Cmb_AgnoEstadMat.AddItem I
    Next I
    Cmb_AgnoEstadMat.Text = Anno

ElseIf MenuInformes = "notas" Then
    Indi = 0
    If tablavacia("codigos_ensenanza", conn) Then
        m1 = "- TIPOS DE ENSEÑANZA" & Chr(13)
        Indi = 1
    End If
    If tablavacia("periodos", conn) Then
        m2 = "- PERÍODOS" & Chr(13)
        Indi = 1
    End If
    If tablavacia("Cursos", conn) Then
        m3 = "- CURSOS" & Chr(13)
        Indi = 1
    End If
    If Indi = 0 Then
        Call LlenaCombo(cmb_agno, "matriculas", "anno_mat", "group by anno_mat order by anno_mat desc", conn)
        cmb_agno.Text = Anno
        Call ordensubsectores
        Set rs = New ADODB.Recordset
        Set rsinforme = New ADODB.Recordset
        Set RsAux = New ADODB.Recordset
        Set rsnotas = New ADODB.Recordset
        Busqueda = 1
        Call Form_main.hideframeimpresion
        Me.lst_nom_alu.Visible = False
        Me.Caption = "Informe de notas"
        Me.Height = 6090
        Me.Width = 8600
        Me.Frame_fuentes.Top = 120
        Me.Frame_fuentes.Left = 120
        Me.Frame_fuentes.Visible = True
        Call LlenaCombo(cmb_mod_notas, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
        rs.CursorLocation = adUseClient
                       
        colegio = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
        rs.Open "select distinct num_per, des_per from periodos order by num_per", conn
        c = 0
        If rs.RecordCount > 0 Then
            If colegio = "FLO001" Then
                ReDim aperiodos(rs.RecordCount + 2)
            Else
                ReDim aperiodos(rs.RecordCount + 1)
            End If
            While Not rs.EOF
                If colegio = "FLO001" Then
                    Me.lst_periodos.AddItem Mid(rs("des_per"), 1, (Len(rs("des_per")) - 9)) & " TRIMESTRE"
                Else
                    Me.lst_periodos.AddItem rs("des_per")
                End If
                
                aperiodos(c) = rs("num_per")
                rs.MoveNext
                c = c + 1
            
            Wend
            If colegio = "FLO001" Then
                Me.lst_periodos.AddItem "TERCER TRIMESTRE"
                aperiodos(2) = 2
                c = c + 1
            End If
            Me.lst_periodos.AddItem "ANUAL"
            aperiodos(c) = "666"
            
            'seleccionar periodo
    
            rs1.Open "SELECT * FROM cfg WHERE param = 'semestre'", conn
                If rs1("valor") = 1 Then
                     Me.lst_periodos.ListIndex = 0
                Else
                    If rs1("valor") = 2 Then
                        Me.lst_periodos.ListIndex = 1
                    Else
                        Me.lst_periodos.ListIndex = 2
                 
                    End If
                End If
            rs1.Close
            'fin seleccionar periodo
                
        Else
            MsgBox "No estan definidos los periodos para este año escolar", vbExclamation, "ALERTA"
            Exit Sub
        End If
        rs.Close
        
        Me.cmb_printers.Clear
        For t = 0 To Printers.count - 1
            Me.cmb_printers.AddItem Printers(t).DeviceName
            Me.cmb_printers.ItemData(Me.cmb_printers.NewIndex) = t
        Next t
        Me.cmb_printers.ListIndex = 0
        CentrarForma Me
        Me.Show
        Me.opt_indiv_gral(0).Value = True
        Me.opt_tipopapel(0).Value = True
        Me.chk_todos_notas.Value = False
        Me.chk_todos_notas.Enabled = False
    Else
        MsgBox ("No es posible continuar, las siguientes tablas" & Chr(13) & "se encuentran vacías : " & Chr(13) & Chr(13) + m1 + m2 + m3 + m4 + m5 + m6 & Chr(13) & Chr(13) & "Ingrese la información correspondiente.")
        Call menuhabilitado(True)
        SendKeys "%{m}"

    End If
ElseIf MenuInformes = "matnuevos" Then
    Set rs = New ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    Call Form_main.hideframeimpresion
    Me.Caption = "Alumnos nuevos"
    Me.Height = 2100
    Me.Width = 5250
    Me.Frame_Mat_Nuevos.Top = 120
    Me.Frame_Mat_Nuevos.Left = 120
    Me.Frame_Mat_Nuevos.Visible = True
    Me.Opt_mat_nuevos(0).Value = True
    CentrarForma Me
End If

'update de validacion, esta pendiente encontrar donde se genera la disrrupcion
conn.Execute "UPDATE alu_x_cur as ac, matriculas as m SET ac.fec_mat=m.fec_mat WHERE ac.ci_alu=m.ci_alu AND ac.agno=m.anno_mat AND ac.activo_alu=m.activo_alu AND m.activo_alu='SI';"

End Sub

Private Sub Form_Unload(Cancel As Integer)
Call menuhabilitado(True)
End Sub

Private Sub lst_nom_alu_DblClick()
Dim rutalumno As String
Dim CodModalidad, NumGra As String
    If val(cmb_agno.Text) <= 0 Then
        MsgBox "Ingrese el año a consultar", vbInformation, "Faltan Datos"
        Exit Sub
    End If
Indi = 0
Busqueda = 0
Busqueapo = 0
Me.lst_nom_alu.Visible = False
rutalumno = aalumnos(lst_nom_alu.ListIndex, 1)
Nombrealumno = aalumnos(lst_nom_alu.ListIndex, 2)
RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
Me.btn_otro_alu.Enabled = True
Me.txt_nom_alu.Enabled = False
RsAux.CursorLocation = adUseClient
If ExistReg("alu_x_cur", "ci_alu = '" & rutalumno & "' and ucase(activo_alu)='SI' and agno='" & Trim(cmb_agno.Text) & "'", conn) Then
    RsAux.Open "select ci_alu, cod_ens, num_gra, let_cur from alu_x_cur where ci_alu = '" & rutalumno & "' and agno=" & cmb_agno.Text & " and ucase(activo_alu)='SI'", conn
    Me.txt_nom_alu.Text = Nombrealumno
    Me.txt_rut_alu.Text = RsAux("ci_alu")
    Me.txt_nivel_alu.Text = RsAux("num_gra")
    Me.txt_letra_alu.Text = RsAux("let_cur")
    Me.txt_mod_alu.Text = DevuelveCampo("codigos_ensenanza", "", "Des_ens", "cod_ens = '" & RsAux("cod_ens") & "'", conn)
    Me.txt_apo_alu.Text = nombreapo & " " & ape1apo & " " & ape2apo
    Me.txt_estado_alu.Text = "ACTIVO"
    RsAux.Close
Else
    RsAux.Open "select ci_alu, cod_ens, num_gra, let_cur from alu_x_cur where ci_alu = '" & rutalumno & "' and agno=" & cmb_agno.Text & " and ucase(activo_alu)='NO' and fec_cam ='1111-11-11' ORDER BY fec_ing_curso DESC LIMIT 1", conn
    If RsAux.RecordCount > 0 Then
        Me.txt_nom_alu.Text = Nombrealumno
        Me.txt_rut_alu.Text = RsAux("ci_alu")
        Me.txt_nivel_alu.Text = RsAux("num_gra")
        Me.txt_letra_alu.Text = RsAux("let_cur")
        Me.txt_mod_alu.Text = DevuelveCampo("codigos_ensenanza", "", "Des_ens", "cod_ens = '" & RsAux("cod_ens") & "'", conn)
        Me.txt_apo_alu.Text = nombreapo & " " & ape1apo & " " & ape2apo
        Me.txt_estado_alu.Text = "RETIRADO"
    End If
    RsAux.Close
End If
    'AQUI VAN LOS DATOS DEL APODERADO //2
End Sub

Private Sub lst_periodos_Click()
' ##################################################################################################
    Dim Num_Periodo
    Num_Periodo = aperiodos(Me.lst_periodos.ListIndex)
    If Num_Periodo = "666" Then
        Opt_destino(1).Enabled = False
        Opt_destino(0).Value = True
        opt_tipopapel(1).Enabled = False
        opt_tipopapel(0).Value = True
        opt_final_parcial(1).Enabled = False
        opt_final_parcial(0).Value = True
        Me.cmb_fuentes.Enabled = False
        Me.cmb_fuentes.Text = "Arial"
    Else
        Me.cmb_fuentes.Enabled = True
        Opt_destino(1).Enabled = True
        opt_tipopapel(1).Enabled = True
        opt_final_parcial(1).Enabled = True
    End If
' ##################################################################################################
End Sub

Private Sub masivo_limpiar_Click()
Unload Me
MenuInformes = "Estadmat"
Load FormFechas
End Sub

Private Sub Opt_dest_reg_Click(Index As Integer)
If Index = 0 Then
    Form_main.CrystalReport.Destination = crptToWindow
Else
    Form_main.CrystalReport.Destination = crptToPrinter
End If
End Sub

Private Sub opt_destino_cartola_Click(Index As Integer)
If Index = 0 Then
    Form_main.CrystalReport.Destination = crptToWindow
Else
    Form_main.CrystalReport.Destination = crptToPrinter
End If
End Sub

Private Sub Opt_destino_Click(Index As Integer)
If Index = 0 Then
    Form_main.CrystalReport.Destination = crptToPrinter
ElseIf Index = 1 Then
    Form_main.CrystalReport.Destination = crptToWindow
End If
End Sub

Private Sub opt_destino_emat_Click(Index As Integer)
If Index = 0 Then
    Form_main.CrystalReport.Destination = crptToWindow
Else
    Form_main.CrystalReport.Destination = crptToPrinter
End If
End Sub

Private Sub opt_destino_registros_Click(Index As Integer)
If Index = 0 Then
    Form_main.CrystalReport.Destination = crptToWindow
Else
    Form_main.CrystalReport.Destination = crptToPrinter
End If
End Sub



Private Sub opt_indiv_gral_Click(Index As Integer)
If Index = 0 Then ' Seleccionó individual
    Me.Opt_destino(1).Enabled = True
    Me.Opt_destino(0).Value = True
    Me.Frame_general.Visible = False
    Me.Frame_individual.Visible = True
    Call btn_otro_alu_Click
ElseIf Index = 1 Then ' Seleccionó general
    Me.Opt_destino(1).Enabled = False
    Me.Opt_destino(0).Value = True
    Me.Frame_individual.Visible = False
    Me.Frame_general.Visible = True
    Me.cmb_mod_notas.Text = ""
    Me.lst_cursosinf.Clear
    Me.chk_todos_notas.Value = False
    Me.chk_todos_notas.Enabled = False
    Me.cmb_mod_notas.SetFocus
End If
End Sub

Private Sub txt_nom_alu_Change()
Dim I As Integer
If Busqueda = 1 Then
    Me.btn_otro_alu.Enabled = False
    rs.CursorLocation = adUseClient
    lst_nom_alu.Clear
    If Not ((Chr(KeyAscii) >= "A" And Chr(KeyAscii) <= "Z") Or (Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z")) Then
        KeyAscii = 0
        If Me.txt_nom_alu.Text <> "" Then
        Criterio = "'" + Me.txt_nom_alu.Text + Consulta + "%'"
        rs.Open "SELECT DISTINCT p.ci_alu, p.ape_pat_alu, p.ape_mat_alu, p.nom_alu FROM postulantes p, alu_x_cur a where p.ci_alu = a.ci_alu and ape_pat_alu like " & Criterio & " order by ape_pat_alu, ape_mat_alu, nom_alu", conn
            'arriba listo todos los alumnos que estan en postulantes y que alguna vez tuvieron
            'curso o sea están en alu_x_cur, le pongo distinct por si se repite.
            lst_nom_alu.Visible = False
            If rs.RecordCount > 0 Then
                ReDim aalumnos(rs.RecordCount, 2)
                Indi = 0
                X = 0
                lst_nom_alu.Visible = True
                While Not rs.EOF
                    'Me.Txt_cod_TipoApo.Text = rs(0)
                    lst_nom_alu.AddItem rs("ape_pat_alu") + " " + rs("ape_mat_alu") + " " + rs("nom_alu")
                    aalumnos(X, 1) = rs("ci_alu")
                    aalumnos(X, 2) = rs("nom_alu") & " " & rs("ape_pat_alu") & " " & rs("ape_mat_alu")
                    rs.MoveNext
                    X = X + 1
                Wend
            Else
                Indi = 0
            End If
            rs.Close
        Else
        lst_nom_alu.Visible = False
        End If
    End If
End If
End Sub

Private Sub txt_nom_alu_KeyPress(KeyAscii As Integer)
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Function ImprimeInformeFinal(ByVal Rutalu As String, Optional ByVal Medio As String = "impr") As Integer
Dim Str_QueryInforme As String
Dim curso As String
Dim Nom_Asi, Nom_Eva, Str_Notas, Nota As String
Dim BordeH, I, c, StartY, TamCdr, Aumento, Int_NumNotas, Int_NumProm As Integer
Dim Dbl_Nota, Dbl_PromPond, Dbl_Pond, Dbl_SumPromFinal As Double

Dim var_sql As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset

    If opt_indiv_gral(1).Value Then
        Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.activo_alu='SI' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
    Else
        Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
    End If
    
    BordeH = 13950
    StartY = 2350
    TamCdr = 500
    RsAux.CursorLocation = adUseClient
    RsAux.Open Str_QueryInforme, conn
    'Si esta vacio salgo y no imprimo
    If (RsAux.EOF = True) Then
        Log_AddAnotacion "Inf. Notas Final - Alumno RUN " & Rutalu & "con problemas de consistencia.", True
        Printer.CurrentX = 1000: Printer.CurrentY = StartY + 200: Printer.Print "Alumno Con Errores, tiene información coherente."
        ImprimeInformeFinal = StartY + 600
        RsAux.Close
        Exit Function
    End If
    '####
    RsAux.MoveFirst
    I = 0
    Int_NumProm = 0
    Dbl_SumPromFinal = 0
    curso = RsAux("num_gra")
    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_asi")

        Printer.Line (50, StartY + (I * TamCdr))-(BordeH, StartY + ((I + 1) * TamCdr)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * TamCdr))-(3200, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Calific 1 sem
            Printer.Line (7000, StartY + (I * TamCdr))-(7000, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * TamCdr))-(7630, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * TamCdr))-(8260, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio calific 2 sem
            Printer.Line (12060, StartY + (I * TamCdr))-(12060, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * TamCdr))-(12690, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * TamCdr))-(13320, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * TamCdr) + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_asi")) Then
            Nom_Eva = RsAux("des_eva")
            Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Nom_Eva)
            Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            ' EXIMIDO???
            If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
            Else
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
            End If
            
            Str_Notas = RsAux("nota")
            c = 0
            Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                Printer.CurrentX = 7100: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            End If
            'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec
            If (Nom_Asi = RsAux("nom_asi") And Nom_Eva = RsAux("des_eva")) Then
                ' EXIMIDO???
                If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                Else
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                End If
                ' prom final
                If (RsAux("cod_asi") <> 13 And val(RsAux("promedio_final")) <> 0) And (RsAux("cod_asi") <> 22 And val(RsAux("promedio_final")) <> 0) Then
                        If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                        Else
                            Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                            Int_NumProm = Int_NumProm + 1
                            Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio_final"), "0.0"))
                        End If
                ElseIf RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                    ' Esta EXIMIDO!
                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                Else
                    Select Case CSng(RsAux("promedio_final"))
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print Promsemestre 'Format(RsAux("promedio_final"), "0.0")
                    
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                    Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                End If
                'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec
                If (Nom_Asi = RsAux("nom_asi")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        Printer.CurrentX = 7100: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    '#########################
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec
                    If (Nom_Asi = RsAux("nom_asi") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        '#########################
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If 'Printer.FontSize = 6: Printer.FontBold = FalsePrinter.FontSize = 6: Printer.FontBold = False
SigSubSec:
        I = I + 1
SigSubSecEx:
    Wend
    
    var_sql = "select valor from cfg where param = 'CODBC'"
    objRS.Open var_sql, conn
    If objRS("valor") = "POD001" And lst_periodos.Text = "ANUAL" Then
                        
        Printer.FontSize = 8: Printer.FontBold = True
        Dim colegio As String
        Dim Sw_Lincoln As Integer
        colegio = UCase(DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn))
        Sw_Lincoln = InStr(1, colegio, "LINCOLN")
        If Not (Sw_Lincoln > 0) Then
            Dbl_SumPromFinal = Dbl_SumPromFinal / Int_NumProm
        Else
            Dbl_SumPromFinal = (Fix((Dbl_SumPromFinal / Int_NumProm) * 10)) / 10
        End If
        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 150: Printer.Print (Format(Dbl_SumPromFinal, "0.0"))
        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 500 + 250: Printer.Print (DevuelveCampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & cmb_agno.Text, conn))
        ' Printer.FontSize = 6: Printer.FontBold = False
        RsAux.Close
    
        ' dibujo el cuadrado para situacion final
        Posi = StartY + (I * TamCdr)
        BordeH = 13950

    
        Printer.FontSize = 6
        Printer.FontSize = 7
        Printer.FontBold = True
        Printer.CurrentX = 12200: Printer.CurrentY = Posi + 30: Printer.Print ("PROMEDIO")
        Printer.CurrentX = 12200: Printer.CurrentY = Posi + 180: Printer.Print ("FINAL ANUAL")

        Printer.FontSize = 6: Printer.FontBold = False
     
        Printer.Line (12060, Posi + 400)-(BordeH, Posi + 400)
        Printer.Line (BordeH, Posi)-(BordeH, Posi + 400)
    
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (12060, Posi)-(12060, Posi + 400) ' linea vertical separacion promedio semestral
            Printer.Line (13320, Posi)-(13320, Posi + 400) ' linea vertical separacion promedio anual
        End If


        Printer.CurrentY = Printer.CurrentY + 1200
        StartY = StartY + 600
        
    
    'Talleres

    var_sql = "select axc.ci_alu, axc.cod_ens,axc.num_gra,axc.let_cur,t.cod_tall,t.nom_tall,nt.num_per," _
            & "pe.des_per,0 as cod_eva,'APRENDIZAJE' as 'des_eva',100 as 'porcentaje_eva',nt.nota, if(nt.num_per=1,p.p1,p.p2) as promedio,p.nf as promedio_final" _
            & " from alu_x_cur axc,notas_talleres nt,promedios_talleres p,talleres t,periodos pe" _
            & " where axc.agno = " & cmb_agno.Text _
            & " and axc.ci_alu = '" & Rutalu & "' and axc.activo_alu = 'SI'" _
            & " and axc.cod_ens = nt.cod_ens and axc.num_gra = nt.num_gra" _
            & " and axc.let_cur = nt.let_cur and axc.ci_alu = nt.ci_alu and axc.agno = nt.agno and" _
            & " nt.Cod_Ens = p.Cod_Ens And nt.Num_Gra = p.Num_Gra And nt.Let_Cur = p.Let_Cur And nt.ci_alu = p.ci_alu" _
            & " and nt.agno = p.agno and nt.cod_tall = p.cod_tall and nt.tipo_tall = p.tipo_tall and" _
            & " p.cod_tall = t.cod_tall and p.cod_ens = t.cod_ens and p.num_gra = t.num_gra and t.tipo_tall = p.tipo_tall and t.tipo_tall = 1 and" _
            & "(nt.num_per-1) = pe.num_per"

    RsAux.CursorLocation = adUseClient
    RsAux.Open var_sql, conn

    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_tall")

        Printer.Line (50, StartY + (I * TamCdr))-(BordeH, StartY + ((I + 1) * TamCdr)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * TamCdr))-(3200, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Calific 1 sem
            Printer.Line (7000, StartY + (I * TamCdr))-(7000, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * TamCdr))-(7630, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * TamCdr))-(8260, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio calific 2 sem
            Printer.Line (12060, StartY + (I * TamCdr))-(12060, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * TamCdr))-(12690, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * TamCdr))-(13320, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * TamCdr) + 150 + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_tall")) Then
            Nom_Eva = RsAux("des_eva")

                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))


            Str_Notas = RsAux("nota")
            c = 0
                                   Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
            End If
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec2
            If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
                ' prom final
                If (val(RsAux("promedio_final")) <> 0) Then
                    Select Case CSng(RsAux("promedio_final") / 10)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                    Int_NumProm = Int_NumProm + 1
                        
                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print Promsemestre ' (Format(RsAux("promedio_final"), "0.0"))
                    End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                    End If
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec2
                If (Nom_Asi = RsAux("nom_tall")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        Printer.CurrentX = 7100: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    '#########################
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec2
                    If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        '#########################
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec2
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec2:
        I = I + 1
    Wend
    RsAux.Close

    'Talleres Electivos
    var_sql = "select axc.ci_alu, axc.cod_ens,axc.num_gra,axc.let_cur,t.cod_tall,t.nom_tall,nt.num_per," _
            & "pe.des_per,0 as cod_eva,'APRENDIZAJE' as 'des_eva',100 as 'porcentaje_eva',nt.nota, if(nt.num_per=1,p.p1,p.p2) as promedio,p.nf as promedio_final" _
            & " from alu_x_cur axc,notas_talleres nt,promedios_talleres p,talleres t,periodos pe" _
            & " where axc.agno = " & cmb_agno.Text _
            & " and axc.ci_alu = '" & Rutalu & "' and axc.activo_alu = 'SI'" _
            & " and axc.cod_ens = nt.cod_ens and axc.num_gra = nt.num_gra" _
            & " and axc.let_cur = nt.let_cur and axc.ci_alu = nt.ci_alu and axc.agno = nt.agno and" _
            & " nt.Cod_Ens = p.Cod_Ens And nt.Num_Gra = p.Num_Gra And nt.Let_Cur = p.Let_Cur And nt.ci_alu = p.ci_alu" _
            & " and nt.agno = p.agno and nt.cod_tall = p.cod_tall and nt.tipo_tall = p.tipo_tall and" _
            & " p.cod_tall = t.cod_tall and p.cod_ens = t.cod_ens and p.num_gra = t.num_gra and t.tipo_tall = p.tipo_tall and t.tipo_tall = 2 and" _
            & "(nt.num_per-1) = pe.num_per"

    RsAux.CursorLocation = adUseClient
    RsAux.Open var_sql, conn

    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_tall")

        Printer.Line (50, StartY + (I * TamCdr))-(BordeH, StartY + ((I + 1) * TamCdr)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * TamCdr))-(3200, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Calific 1 sem
            Printer.Line (7000, StartY + (I * TamCdr))-(7000, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * TamCdr))-(7630, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * TamCdr))-(8260, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio calific 2 sem
            Printer.Line (12060, StartY + (I * TamCdr))-(12060, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * TamCdr))-(12690, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * TamCdr))-(13320, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * TamCdr) + 150 + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_tall")) Then
            Nom_Eva = RsAux("des_eva")

                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
            Str_Notas = RsAux("nota")
            c = 0
                                   Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                Printer.CurrentX = 7100: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            End If
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec3
            If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
                If val(RsAux("promedio_final")) <> 0 Then
                   Select Case CSng(RsAux("promedio_final") / 10)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                        Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                        Int_NumProm = Int_NumProm + 1
                        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print Promsemestre '(Format(RsAux("promedio_final"), "0.0"))
                    End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                    Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                End If
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec3
                If (Nom_Asi = RsAux("nom_tall")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        Printer.CurrentX = 7100: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    '#########################
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec3
                    If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        '#########################
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec3
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec3:
        I = I + 1
    Wend
    ImprimeInformeFinal = StartY + (I * TamCdr)
    objRS.Close
    If curso < 3 Then RsAux.Close
 Else
    
    Printer.FontSize = 8: Printer.FontBold = True
    colegio = UCase(DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn))
    Sw_Lincoln = InStr(1, colegio, "LINCOLN")
    If Not (Sw_Lincoln > 0) Then
        Dbl_SumPromFinal = Dbl_SumPromFinal / Int_NumProm
    Else
        Dbl_SumPromFinal = (Fix((Dbl_SumPromFinal / Int_NumProm) * 10)) / 10
    End If
    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 150: Printer.Print (Format(Dbl_SumPromFinal, "0.0"))
    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 500: Printer.Print (DevuelveCampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & cmb_agno.Text, conn))
    Printer.FontSize = 6: Printer.FontBold = False
    RsAux.Close
    ImprimeInformeFinal = StartY + (I * TamCdr)
    objRS.Close
End If
End Function

Private Sub ImprimeInformeFinalCab(ByVal rutalumno As String, ByVal Ngrado As String, ByVal letra As String, ByVal NombreModalidad)

    Dim BordeH As Integer

    Call EncabezadoInformeFinal(True)
    ' aqui averiguo el tipo del informe, osea final o parcial para
    ' imprimir el titulo.
    If Me.opt_final_parcial(0) Then
        Tipoinforme = UCase(Me.opt_final_parcial(0).Caption)
    ElseIf Me.opt_final_parcial(1) Then
        Tipoinforme = UCase(Me.opt_final_parcial(1).Caption)
    End If
    BordeH = 13950
    Printer.FontSize = 9
    Call centrarenpapel(1000, Tipoinforme & " " & Me.lst_periodos.Text & " " & cmb_agno.Text)  ' Este año debe ser el de proceso NO DEL SISTEMA
    ' ACABO DE IMPRIMIR EL TITULO CENTRADO
    Printer.FontSize = 8
    Printer.CurrentX = 100: Printer.CurrentY = 1300: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 1300: Printer.Print (": ")
    Printer.CurrentX = 100: Printer.CurrentY = 1500: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 1500: Printer.Print (": ")
    Printer.CurrentX = 100: Printer.CurrentY = 1700: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 1700: Printer.Print (": ")
    ' Info del alumno caso general
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "'", conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    
    Printer.FontSize = 8
    Printer.CurrentX = 1600: Printer.CurrentY = 1300: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1600: Printer.CurrentY = 1500: Printer.Print (Ngrado & "º " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1600: Printer.CurrentY = 1700: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    ' #################
    
    Printer.FontBold = False
    Printer.Line (50, 2000)-(BordeH, 2350), , B ' ESTE ES EL PRIMER BOX DEL INFORME

    Printer.FontSize = 7
    Printer.CurrentX = 100: Printer.CurrentY = 2100: Printer.Print ("A S I G N A T U R A S")
    Printer.FontSize = 6
    Printer.CurrentX = 4000: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 1º Periodo")
    Printer.CurrentX = 9060: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 2º Periodo")
     
    Aumento = 0
    Printer.FontSize = 6
    Aumento = 0
    For t = 1 To 14
        Aumento = 250 * t
        Printer.CurrentY = 2200
        Printer.CurrentX = 3150 + Aumento
        Printer.Print (t)
        Printer.CurrentY = 2200
        Printer.CurrentX = 8210 + Aumento
        Printer.Print (t)
    Next t
    
    Printer.CurrentX = 7025: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 7025: Printer.CurrentY = 2200: Printer.Print ("Ponderado")
    Printer.CurrentX = 7670: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 7670: Printer.CurrentY = 2200: Printer.Print ("1º Periodo")
    Printer.CurrentX = 12085: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 12085: Printer.CurrentY = 2200: Printer.Print ("Ponderado")
    Printer.CurrentX = 12730: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 12730: Printer.CurrentY = 2200: Printer.Print ("2º Periodo")
    Printer.CurrentX = 13360: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 13360: Printer.CurrentY = 2200: Printer.Print ("Final")
    
    If Me.chk_lineasverticales.Value = 0 Then
        Printer.Line (3200, 2000)-(3200, 2350) ' linea vertical
        Printer.Line (7000, 2000)-(7000, 2350) ' linea vertical
        Printer.Line (7630, 2000)-(7630, 2350) ' linea vertical
        Printer.Line (8260, 2000)-(8260, 2350) ' linea vertical
        Printer.Line (12060, 2000)-(12060, 2350) ' linea vertical
        Printer.Line (12690, 2000)-(12690, 2350) ' linea vertical
        Printer.Line (13320, 2000)-(13320, 2350) ' linea vertical
    End If
    
End Sub

Private Sub EncabezadoInformeFinal(ByVal negrita As Boolean)
On Error GoTo Errimpresion
Dim colegio As String, Fecha As String, hora As String, direccion As String, localidad As String
colegio = DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn)
direccion = DevuelveCampo("establecimientos", "", "dir_est", "rdb <> ''", conn)
localidad = DevuelveCampo("establecimientos", "", "localidad_est", "rdb <> ''", conn)
anchopagina = Printer.Width - 1500
Largopagina = Printer.Height
Printer.FontBold = negrita
' Aquí imprimo los datos del establecimiento
Printer.CurrentX = 100: Printer.CurrentY = 200: Printer.Print (colegio)
Printer.CurrentX = 100: Printer.CurrentY = 400: Printer.Print (direccion)
Printer.CurrentX = 100: Printer.CurrentY = 600: Printer.Print (localidad)
' Aquí imprimo la fecha y hora del sistema
Printer.CurrentX = anchopagina - 2440: Printer.CurrentY = 200: Printer.Print ("FECHA")
Printer.CurrentX = anchopagina - 2440: Printer.CurrentY = 400: Printer.Print ("HORA")
Printer.CurrentX = anchopagina - 1840: Printer.CurrentY = 200: Printer.Print (":")
Printer.CurrentX = anchopagina - 1840: Printer.CurrentY = 400: Printer.Print (":")
Printer.CurrentX = anchopagina - 1740: Printer.CurrentY = 200: Printer.Print (Date)
Printer.CurrentX = anchopagina - 1740: Printer.CurrentY = 400: Printer.Print (Time)
Printer.FontBold = False
Exit Sub
Errimpresion:

End Sub

Sub ImprimePieInformeFinal(posicion As Integer, CodModalidad As String, Ngrado As String, letra As String, Rutalu As String)
' bueno necesito saber el codigo de la modalidad el nivel y la letra porque debo
' imprimir el nombre del profesor jefe.
Dim I As Single
Dim BordeH As Integer
'variables calculo de porcentaje asistencia
Dim RC2 As ADODB.Recordset
Set RC2 = New ADODB.Recordset
Dim var_sql As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset

'Aqui empieza a dibujarse todo lo que viene después de las notas
'donde empieza el cuadrado con la información del pie de la página
I = posicion + 25 'Esta variable indica la posición de donde se empezará a dibujar
'el pie de página
BordeH = 13950
Printer.Line (50, I)-(50, I + 400)
Printer.Line (50, I)-(BordeH, I)
Printer.Line (BordeH, I)-(BordeH, I + 400)
Printer.Line (50, I + 400)-(BordeH, I + 400)

'calculo el porcentaje de asistencia
        RC2.Open "SELECT sum(asi_r) as ideal, sum(asi_t) as reales  FROM `asistencia`  where agno= " & cmb_agno.Text & " AND ci_alu =  '" & Rutalu & "'", conn
        If RC2("ideal") = 0 Then
            strasis = ""
        Else
            If IsNull(RC2("ideal")) Then
                strasis = "100%"
            Else
                dias = (RC2("reales") * 100) / RC2("ideal")
                strasis = FormatNumber(dias, 1) & "%"
            End If
        End If
        RC2.Close
  
 var_sql = "select valor from cfg where param = 'CODBC'"
 objRS.Open var_sql, conn
 If objRS("valor") <> "POD001" And lst_periodos.Text = "ANUAL" Then
  
'fin calculo
'dibujo el cuadrado para situacion final
Printer.Line (12060, I + 800)-(BordeH, I + 800)
Printer.Line (BordeH, I)-(BordeH, I + 800)
 End If
 


Printer.FontSize = 8


Printer.CurrentX = 200: Printer.CurrentY = I + 650: Printer.Print ("OBSERVACIONES")
Printer.Line (200 + Printer.TextWidth("OBSERVACIONES") + 100, I + 800)-(BordeH - 2500, I + 800)
Printer.Line (200, I + 1100)-(BordeH - 2500, I + 1100)
cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
If cole = "SNB001" Then
' aqui san bernardo pidieron quitar esto 2020
Else
    Printer.CurrentX = 200: Printer.CurrentY = I + 150: Printer.Print ("Porcentaje de Asistencia : " & strasis)
End If
'Rescatando rut del profesor
RutProfe = DevuelveCampo("cursos", "", "rut_prof", "agno=" & cmb_agno.Text & " and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'", conn)
'Rescatando nombre completo y horario del profesor
rs.CursorLocation = adUseClient
rs.Open "select noms_prof, ape1_prof, ape2_prof, hor_ate_prof from profesores where rut_prof = '" & RutProfe & "'", conn
If rs.RecordCount Then
    nombreprofe = rs("noms_prof")
    ape1profe = rs("ape1_prof")
    ape2profe = rs("ape2_prof")
    horario = "" 'Rs("hor_ate_prof")
End If
rs.Close
'Rescatando Nombre completo del(a) director(a)
rs.CursorLocation = adUseClient
rs.Open "select rdb,nom_dir, ape_pat_dir, ape_mat_dir,nom_dir_sub, ape_pat_dir_sub, ape_mat_dir_sub from establecimientos", conn
If rs.RecordCount Then
    RDB = rs("rdb")
    If RDB = "26260-9" Then
        Nombredir = rs("nom_dir_sub")
        ape1dir = rs("ape_pat_dir_sub")
        ape2dir = rs("ape_mat_dir_sub")
    Else
        Nombredir = rs("nom_dir")
        ape1dir = rs("ape_pat_dir")
        ape2dir = rs("ape_mat_dir")
    End If
End If
rs.Close

Printer.CurrentX = 2500: Printer.CurrentY = I + 150: Printer.Print (horario)

If Me.opt_final_parcial(0) Then
    modo = Me.opt_final_parcial(0).Caption
Else
    modo = Me.opt_final_parcial(1).Caption
End If

Listadetablas = Mid(Listadetablas, poscoma + 1, Len(Listadetablas))

'#########################
Printer.FontSize = 7
Printer.FontBold = True
'If objRS("valor") <> "PUD001" And lst_periodos.Text = "ANUAL" Then
If lst_periodos.Text = "ANUAL" Then
    Printer.CurrentX = 12200: Printer.CurrentY = I + 30: Printer.Print ("PROMEDIO")
    Printer.CurrentX = 12200: Printer.CurrentY = I + 180: Printer.Print ("FINAL ANUAL")
    Printer.CurrentX = 12200: Printer.CurrentY = I + 430: Printer.Print ("SITUACION")
    Printer.CurrentX = 12200: Printer.CurrentY = I + 580: Printer.Print ("FINAL")
    'If Me.opt_indiv_gral(0) Then
     Printer.CurrentX = 13420: Printer.CurrentY = I + 430: Printer.Print (DevuelveCampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & Anno, conn))
    'End If
'Else
'    Printer.CurrentX = 12200: Printer.CurrentY = i + 30: Printer.Print ("SITUACION")
'    Printer.CurrentX = 12200: Printer.CurrentY = i + 180: Printer.Print ("FINAL")
End If

If Ngrado > 2 Then
    'Printer.CurrentX = 13420: Printer.CurrentY = i + 100: Printer.Print (devuelvecampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & Anno, conn))
End If


Printer.FontSize = 8
Printer.FontBold = False
If objRS("valor") <> "POD001" And lst_periodos.Text = "ANUAL" Then
If Me.chk_lineasverticales.Value = 0 Then
    Printer.Line (12060, I)-(12060, I + 800) ' linea vertical separacion promedio semestral
    Printer.Line (13320, I)-(13320, I + 800) ' linea vertical separacion promedio anual
End If
Else
If Me.chk_lineasverticales.Value = 0 Then
    Printer.Line (12060, I)-(12060, I + 400) ' linea vertical separacion promedio semestral
    Printer.Line (13320, I)-(13320, I + 400) ' linea vertical separacion promedio anual
End If
End If
objRS.Close


'#########################

Nombreprofejefe = nombreprofe & " " & ape1profe & " " & ape2profe
Cargo1 = "PROFESOR(A) JEFE"
Nombredirec = Nombredir & " " & ape1dir & " " & ape2dir
'If RDB = "26260-9" Then
'    Cargo2 = "DIRECTORA SUBROGANTE"
'Else
    Cargo2 = "DIRECTOR(A)"
'End If

    mitad = (BordeH / 2) / 2
    largotexto = Printer.TextWidth(Nombreprofejefe)
    linea1 = mitad - (largotexto / 2)
    Printer.Line (linea1, I + 1600)-(linea1 + Printer.TextWidth(Nombreprofejefe), I + 1600) ' linea de firma del profesor jefe
    Printer.CurrentX = linea1: Printer.CurrentY = I + 1650: Printer.Print (Nombreprofejefe)
    largotexto = Printer.TextWidth(Cargo1) ' calculo la posicion del cargo del profe
    linea1 = mitad - (largotexto / 2)
    Printer.CurrentX = linea1: Printer.CurrentY = I + 1800: Printer.Print (Cargo1)
'***************************************************************************************
    mitad = (BordeH / 2) / 2
    largotexto = Printer.TextWidth(Nombredirec)
    linea2 = mitad - (largotexto / 2) + (BordeH / 2)
    Printer.Line (linea2, I + 1600)-(linea2 + Printer.TextWidth(Nombredirec), I + 1600) ' linea de firma de la directora
    Printer.CurrentX = linea2: Printer.CurrentY = I + 1650: Printer.Print (Nombredirec)
    largotexto = Printer.TextWidth(Cargo2)
    linea2 = mitad - (largotexto / 2) + (BordeH / 2)
    Printer.CurrentX = linea2: Printer.CurrentY = I + 1800: Printer.Print (Cargo2)
End Sub


Sub ImprimePieInformeFinal_tri(posicion As Integer, CodModalidad As String, Ngrado As String, letra As String, Rutalu As String)
' bueno necesito saber el codigo de la modalidad el nivel y la letra porque debo
' imprimir el nombre del profesor jefe.
Dim I As Single
Dim BordeH As Integer
'variables calculo de porcentaje asistencia
Dim RC2 As ADODB.Recordset
Set RC2 = New ADODB.Recordset
Dim var_sql As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset

'Aqui empieza a dibujarse todo lo que viene después de las notas
'donde empieza el cuadrado con la información del pie de la página
I = posicion + 25 'Esta variable indica la posición de donde se empezará a dibujar
'el pie de página
BordeH = 14100
Printer.Line (50, I)-(50, I + 400)
Printer.Line (50, I)-(BordeH, I)
Printer.Line (BordeH, I)-(BordeH, I + 400)
Printer.Line (50, I + 400)-(BordeH, I + 400)

'calculo el porcentaje de asistencia
        RC2.Open "SELECT sum(asi_r) as ideal, sum(asi_t) as reales  FROM `asistencia`  where agno= " & cmb_agno.Text & " AND ci_alu =  '" & Rutalu & "'", conn
        If RC2("ideal") = 0 Then
            strasis = ""
        Else
            If IsNull(RC2("ideal")) Then
                strasis = "100%"
            Else
                dias = (RC2("reales") * 100) / RC2("ideal")
                strasis = FormatNumber(dias, 1) & "%"
            End If
        End If
        RC2.Close
  
 var_sql = "select valor from cfg where param = 'CODBC'"
 objRS.Open var_sql, conn
 If objRS("valor") <> "POD001" And lst_periodos.Text = "ANUAL" Then
  
'fin calculo
'dibujo el cuadrado para situacion final
Printer.Line (12550, I + 800)-(BordeH, I + 800)
Printer.Line (BordeH, I)-(BordeH, I + 800)
 End If
 


Printer.FontSize = 6


Printer.CurrentX = 200: Printer.CurrentY = I + 650: Printer.Print ("OBSERVACIONES")
Printer.Line (200 + Printer.TextWidth("OBSERVACIONES") + 100, I + 800)-(BordeH - 2000, I + 800)
Printer.Line (200, I + 1100)-(BordeH - 2000, I + 1100)
cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
If cole = "SNB001" Then
' aqui san bernardo pidieron quitar esto 2020
Else
    Printer.CurrentX = 200: Printer.CurrentY = I + 150: Printer.Print ("Porcentaje de Asistencia : " & strasis)
End If
'Rescatando rut del profesor
RutProfe = DevuelveCampo("cursos", "", "rut_prof", "agno=" & cmb_agno.Text & " and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'", conn)
'Rescatando nombre completo y horario del profesor
rs.CursorLocation = adUseClient
rs.Open "select noms_prof, ape1_prof, ape2_prof, hor_ate_prof from profesores where rut_prof = '" & RutProfe & "'", conn
If rs.RecordCount Then
    nombreprofe = rs("noms_prof")
    ape1profe = rs("ape1_prof")
    ape2profe = rs("ape2_prof")
    horario = "" 'Rs("hor_ate_prof")
End If
rs.Close
'Rescatando Nombre completo del(a) director(a)
rs.CursorLocation = adUseClient
rs.Open "select nom_dir, ape_pat_dir, ape_mat_dir from establecimientos", conn
If rs.RecordCount Then
    Nombredir = rs("nom_dir")
    ape1dir = rs("ape_pat_dir")
    ape2dir = rs("ape_mat_dir")
End If
rs.Close

Printer.CurrentX = 2500: Printer.CurrentY = I + 150: Printer.Print (horario)

If Me.opt_final_parcial(0) Then
    modo = Me.opt_final_parcial(0).Caption
Else
    modo = Me.opt_final_parcial(1).Caption
End If

Listadetablas = Mid(Listadetablas, poscoma + 1, Len(Listadetablas))

'#########################
Printer.FontSize = 6
Printer.FontBold = True
'If objRS("valor") <> "PUD001" And lst_periodos.Text = "ANUAL" Then
If lst_periodos.Text = "ANUAL" Then
    Printer.CurrentX = 12650: Printer.CurrentY = I + 30: Printer.Print ("PROMEDIO")
    Printer.CurrentX = 12650: Printer.CurrentY = I + 180: Printer.Print ("FINAL ANUAL")
    Printer.CurrentX = 12650: Printer.CurrentY = I + 430: Printer.Print ("SITUACION")
    Printer.CurrentX = 12650: Printer.CurrentY = I + 580: Printer.Print ("FINAL")
    'If Me.opt_indiv_gral(0) Then
     Printer.CurrentX = 13420: Printer.CurrentY = I + 430: Printer.Print (DevuelveCampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & Anno, conn))
    'End If
'Else
'    Printer.CurrentX = 12200: Printer.CurrentY = i + 30: Printer.Print ("SITUACION")
'    Printer.CurrentX = 12200: Printer.CurrentY = i + 180: Printer.Print ("FINAL")
End If

If Ngrado > 2 Then
    'Printer.CurrentX = 13420: Printer.CurrentY = i + 100: Printer.Print (devuelvecampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & Anno, conn))
End If


Printer.FontSize = 6
Printer.FontBold = False
If objRS("valor") <> "POD001" And lst_periodos.Text = "ANUAL" Then
If Me.chk_lineasverticales.Value = 0 Then
    Printer.Line (12550, I)-(12550, I + 800) ' linea vertical separacion promedio semestral
    Printer.Line (13530, I)-(13530, I + 800) ' linea vertical separacion promedio anual
End If
Else
If Me.chk_lineasverticales.Value = 0 Then
    Printer.Line (12550, I)-(12500, I + 400) ' linea vertical separacion promedio semestral
    Printer.Line (13530, I)-(13530, I + 400) ' linea vertical separacion promedio anual
End If
End If
objRS.Close


'#########################

Nombreprofejefe = nombreprofe & " " & ape1profe & " " & ape2profe
Cargo1 = "PROFESOR(A) JEFE"
Nombredirec = Nombredir & " " & ape1dir & " " & ape2dir
Cargo2 = "DIRECTOR(A)"

    mitad = (BordeH / 2) / 2
    largotexto = Printer.TextWidth(Nombreprofejefe)
    linea1 = mitad - (largotexto / 2)
    Printer.Line (linea1, I + 1600)-(linea1 + Printer.TextWidth(Nombreprofejefe), I + 1600) ' linea de firma del profesor jefe
    Printer.CurrentX = linea1: Printer.CurrentY = I + 1650: Printer.Print (Nombreprofejefe)
    largotexto = Printer.TextWidth(Cargo1) ' calculo la posicion del cargo del profe
    linea1 = mitad - (largotexto / 2)
    Printer.CurrentX = linea1: Printer.CurrentY = I + 1800: Printer.Print (Cargo1)
'***************************************************************************************
    mitad = (BordeH / 2) / 2
    largotexto = Printer.TextWidth(Nombredirec)
    linea2 = mitad - (largotexto / 2) + (BordeH / 2)
    Printer.Line (linea2, I + 1600)-(linea2 + Printer.TextWidth(Nombredirec), I + 1600) ' linea de firma de la directora
    Printer.CurrentX = linea2: Printer.CurrentY = I + 1650: Printer.Print (Nombredirec)
    largotexto = Printer.TextWidth(Cargo2)
    linea2 = mitad - (largotexto / 2) + (BordeH / 2)
    Printer.CurrentX = linea2: Printer.CurrentY = I + 1800: Printer.Print (Cargo2)
End Sub



Sub Imprimeencabezadopant_hue()
Call encabezadopapel_hue(True)

' aqui invoco a una funcion que imprime el membrete
' aqui averiguo el tipo del informe, osea final o parcial para
' imprimir el titulo.
If Me.opt_final_parcial(0) Then
    Tipoinforme = "INFORME FINAL DE NOTAS"
ElseIf Me.opt_final_parcial(1) Then
    Tipoinforme = "INFORME PARCIAL DE NOTAS"
End If
Printer.FontSize = 11
Printer.FontBold = True
Call centrarenpapel(300, Tipoinforme & " " & lst_periodos.Text & " " & cmb_agno.Text)    ' Este año debe ser el de proceso NO DEL SISTEMA
' ACABO DE IMPRIMIR EL TITULO CENTRADO
Printer.FontSize = 8
Printer.PaintPicture LoadPicture("aguilita.gif"), 10000, 980
Printer.CurrentX = 100: Printer.CurrentY = 2600: Printer.Print ("RUT ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 2600: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 2900: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 2900: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 3200: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 3200: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 3500: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 3500: Printer.Print (":")

' Este es el cuadrado de la asistencia

Printer.FontBold = False
Printer.Line (50, 2400)-(11500, 3800), , B  ' ESTE ES EL PRIMER BOX DEL INFORME
Printer.FontBold = True
Printer.FontSize = 10
Printer.CurrentX = 100: Printer.CurrentY = 4050: Printer.Print ("A S I G N A T U R A S")
Printer.FontBold = False
Printer.FontSize = 8
Aumento = 0
Printer.FontSize = 8
For t = 1 To 17
    Aumento = Aumento + 350 + 52
    Printer.CurrentX = 3400
    Printer.CurrentX = Printer.CurrentX + Aumento
    Printer.CurrentY = 4150 'altura de notas
    Printer.Print (t)
Next t
'Printer.CurrentX = 10700: Printer.CurrentY = 4000: Printer.Print ("Promedio")
'Printer.CurrentX = 10690: Printer.CurrentY = 4150: Printer.Print ("Semestre")

Printer.CurrentX = 10700: Printer.CurrentY = 4000: Printer.Print ("  P       P")
Printer.CurrentX = 10690: Printer.CurrentY = 4150: Printer.Print ("  S       C")

If Me.chk_lineasverticales.Value = 0 Then
End If
End Sub

Function Imprimenotasalumnopant_hue(rutalumno As String, Ngrado As String, letra As String, CodModalidad As String, NombreModalidad As String, numperiodo As String) As Long
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim Promsemestre As String
    Dim cole As String
    Dim notass As String
    Dim notass2 As String
    Dim a As Integer, b As Integer, c As Integer
    Dim m1 As String, m2 As String, m3 As String
    'Dim mayor1 As String, mayor2 As String, mayor3 As String
    Dim p1 As Integer, p2 As Integer, p3 As Integer, sw As Integer
    
    
    Dim y1, y2, y3, cont, contt, prom As Double
    '
    Dim Promproceso As Single, Promponderado As Single, valnota As Single   'notasincoma As Single, nota As Single,
    ci_alu = DevuelveCampo("postulantes", "", "ci_alu", "ci_alu ='" & rutalumno & "'", conn)
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
    Printer.FontSize = 8
    Printer.CurrentX = 1500: Printer.CurrentY = 2600: Printer.Print (ci_alu)
    Printer.CurrentX = 1500: Printer.CurrentY = 2900: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1500: Printer.CurrentY = 3200: Printer.Print (Ngrado & " " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1500: Printer.CurrentY = 3500: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    Dim RsAux As ADODB.Recordset
    
    Dim pro As String 'promedio curso asignatura
    Dim especial As Integer
    Dim especial_prom As Double
    Dim especial_promc As Double
    Dim posy As Integer
    Dim posx As Integer
    Dim inglesvar As Integer
    Dim inglesprom As Double
    
    Dim mayor1 As Double
    Dim mayor2 As Double
    Dim mayor3 As Double
    
    Dim posy2 As Integer
    Dim posx2 As Integer
    
    Dim promleng As Double
    Dim tnotasl As Integer
    
    sw = 0
    posy = 0
    posx = 0
    inglesvar = 0
    inglesprom = 0
    tnotasl = 1
    
    posy2 = 0
    posx2 = 0
    
    Set RsAux = New ADODB.Recordset
    RsAux.CursorLocation = adUseClient
'    var_sql = "select *" _
'            & " from subsectores s,asi_x_cur_prof ap" _
'            & " where s.num_gra = ap.num_gra and s.cod_asi = ap.cod_asi and s.cod_ens = ap.cod_ens and" _
'            & " ap.cod_ens = '" & CodModalidad & "' and ap.num_gra = '" & Ngrado & "' and ord_asi <> 0 and ap.let_cur = '" & Letra & "'" _
'            & " and agno = " & cmb_agno.Text & " order by ord_asi"

   'Volver atras
    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and ci_alu = '" & rutalumno & "' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
    Else
    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
    End If
' Ahora se muestran asignaturas sin notas en informe
'    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
'    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi ORDER BY ord_asi"
'    Else
'    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi ORDER BY ord_asi"
'    End If
    
    
    
    RsAux.Open var_sql, conn
    'Aqui acabo de seleccionar los sectores y asignaturas correspondientes al nivel del alumno.
    promfinal = 0: Sumapromedios = 0
    
    If RsAux.RecordCount > 0 Then 'Si se encontraron asignaturas en el curso
        Dim rsnotas As ADODB.Recordset
        Set rsnotas = New ADODB.Recordset

        Aumentosector = 0 '****Separacion vertical nombre subsectores****
        Totalsubsectores = 0
        y1 = 4000 '**Posicion recuadro notas**
        prom = 0
        cont = 0
        ydeproceso = 3920 '**Posicion inicial impresion de notas**
        Printer.Line (50, CLng(3900))-(11500, CLng(3900 + 500)), , B '**Tercer recuadro informe subsectores**
        
        
                
            While Not RsAux.EOF
                y1 = y1 + 400
                
                Sector = RsAux("cod_sec")
                Codasi = RsAux("cod_asi")
                Nombreasig = RsAux("nom_asi")
                
                
                'pregunta si subsector es ingles
                If cole = "ALT001" And val(Sector) = 14 And val(Codasi) = 8 And val(Ngrado) >= 1 And val(Ngrado) <= 4 And CodModalidad = "110" Then
                    inglesvar = 1
                Else
                    inglesvar = 0
                End If
                
                
                'pregunta para dejar el recuadro de las notas con sangria
                If (val(Ngrado) = 7 Or val(Ngrado) = 8) And (val(Sector) = 3 And val(Codasi) = 5 Or val(Codasi) = 6 Or val(Codasi) = 7) Then
                    Printer.Line (400, CLng(y1))-(11500, CLng(y1 + 400)), , B '**Recuadro horizontal notas**
                    especial = 1
                Else
                    Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 400)), , B '**Recuadro horizontal notas**
                    especial = 0
                End If
                
                rsnotas.Open "select cod_sec, cod_asi, num_per, cod_eva, MID(nota,1,24) AS nota from notas where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "' and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and num_per = '" & numperiodo & "' and agno = " & cmb_agno.Text & " order by cod_sec, cod_asi", conn
                If rsnotas.RecordCount > 0 Then
                    notass2 = rsnotas("nota")
                End If
                Aumentosector = Aumentosector + 400
                Printer.CurrentY = 4080 'Altura donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                
                If especial = 1 Then
                    Printer.CurrentX = 500
                Else
                    Printer.CurrentX = 100
                End If
                
                Printer.FontSize = 8
                Printer.Print (Nombreasig) 'Imprimo nombre asignatura
                
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 410
                
                If (val(Sector) = 3 And val(Codasi) = 20) Then
                        posy = 5700
                        posx = 10700
                End If
                
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Or (val(Sector) = 3 And val(Codasi) = 20) Then
                    notas = rsnotas("nota")
                    
                    If (val(Sector) = 3 And val(Codasi) = 20) Then
                        posy = 5700
                        posx = 10700
                    End If
                    
                    For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408 'separacion horizontal de notas
                                
                        Printer.CurrentX = 3300 'Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                 
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                            
                            
                            'acumula nota leng
                         If val(Sector) = 14 And val(Codasi) = 14 Then
                                    promleng = promleng + notasincoma
                         End If
                         
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0")) 'aqui debo dejar un numero entero 4 como 4,0
                        End If 'sin necesidad de agregarle coma como texto
                        Divisor = Divisor + 1
                    Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        
                        'si el ramo es ingles guarda la nota ORDENAMIENTO
                If (val(Sector) = 14 And val(Codasi) = 8) Then
                                notass = notass2
                        m1 = 10
                        For a = 1 To 12
                           If val(Mid(notas, (a * 2) - 1, 2)) <> 0 Then
                           If CInt(m1) < CInt(Mid(notas, (a * 2) - 1, 2)) Then
                              m1 = Mid(notas, (a * 2) - 1, 2)
                              p1 = a
                           End If
                           End If
                        Next a
                        
                        m2 = 10
                        For a = 1 To 12
                           If val(Mid(notas, (a * 2) - 1, 2)) <> 0 Then
                           If CInt(m2) < CInt(Mid(notas, (a * 2) - 1, 2)) And a <> p1 Then
                              m2 = Mid(notas, (a * 2) - 1, 2)
                              p2 = a
                           End If
                           End If
                        Next a
                        
                        m3 = 10
                        For a = 1 To 12
                           If val(Mid(notas, (a * 2) - 1, 2)) <> 0 Then
                           If CInt(m3) < CInt(Mid(notas, (a * 2) - 1, 2)) And a <> p1 And a <> p2 Then
                              m3 = Mid(notas, (a * 2) - 1, 2)
                              p3 = a
                           End If
                           End If
                        Next a
                        
                        'Estas son las 3 notas mayores
                        mayor1 = m1
                        mayor2 = m2
                        mayor3 = m3
                        
                        inglesprom = mayor1 + mayor2 + mayor3
                        If cole = "HUE001" Then
                            inglesprom = 0
                            tnotasl = -3
                        End If
                                
                End If
                
                        'si el ramo es compresion del medio no imprime notas debido a que este seria solo un encanbezado
                        If (val(Ngrado) = 7 Or val(Ngrado) = 8) And (val(Sector) = 3 And val(Codasi) = 20) Then
                        Else
                            'imprime notas
                        If rsnotas("cod_asi") = 13 Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = 13 and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                'Printer.Print ("Ex.")
                            Else
                                Printer.Print (Nota)
                            End If
                        Else
                            Printer.Print (Nota)
                        End If
                            
                            
                            
                            
                            
                            
                            'Printer.Print (Nota)
                        End If
                        
                        Printer.FontBold = False
                        
'                    If Val(Sector) = 14 And Val(Codasi) = 14 Then
'                        tnotasl = tnotas
'                    End If
                    Next tnotas
                    
                    If val(Sector) = 14 And val(Codasi) = 14 Then
                        tnotasl = ((Len(notas)) / 2)
                    End If
                    
                    End If
                End If
                rsnotas.Close
            
'CONSULTA PROMEDIO ASIGNATURA
If numperiodo = 0 Then
    rsnotas.Open "select REPLACE(mid(SUM(p1)/COUNT(p1),1,3), '.', ',') as pro FROM promedios p, alu_x_cur ac where ac.cod_ens = '" & CodModalidad & "' and ac.num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "' and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and ac.agno = " & cmb_agno.Text & " and p1 <> 0 AND activo_alu = 'si' AND ac.ci_alu = p.ci_alu AND ac.agno = p.agno  AND p.cod_ens = ac.cod_ens AND p.num_gra = ac.num_gra AND p.letra_curso = ac.let_cur order by cod_sec, cod_asi", conn
Else
    rsnotas.Open "select REPLACE(mid(SUM(p2)/COUNT(p2),1,3), '.', ',') as pro FROM promedios p, alu_x_cur ac where ac.cod_ens = '" & CodModalidad & "' and ac.num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "' and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and ac.agno = " & cmb_agno.Text & " and p2 <> 0 AND activo_alu = 'si' AND ac.ci_alu = p.ci_alu AND ac.agno = p.agno  AND p.cod_ens = ac.cod_ens AND p.num_gra = ac.num_gra AND p.letra_curso = ac.let_cur order by cod_sec, cod_asi", conn
End If
    
    If Not IsNull(rsnotas("pro")) Then
        pro = rsnotas("pro")
    End If
    
    rsnotas.Close
'FIN CONSULTA PROMEDIO ASIGNATURA
                
                rsnotas.Open "select * from promedios where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and agno = " & cmb_agno.Text & " order by cod_sec, cod_asi", conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10700 'ubicacion notas promedio
                    If numperiodo = 0 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    If Nota < 4# Then
                        Printer.FontBold = False
                    Else
                        Printer.FontBold = False
                    End If
                                                       
                    
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    
                    Select Case CSng(val(pro))
                            Case 0 To 0.9
                                procur = "EX"
                            Case 1# To 3.9
                                procur = "I"
                            Case 4# To 4.9
                                procur = "S"
                            Case 5# To 5.9
                                procur = "B"
                            Case 6# To 7#
                                procur = "MB"
                    End Select
                    
                    If rsnotas("cod_asi") <> 13 Then
                        If val(Replace(Nota, ",", ".")) <> "0,0" Then
                                If Not ((rsnotas("cod_asi") = 5 Or rsnotas("cod_asi") = 6 Or rsnotas("cod_asi") = 7) And CodModalidad = "110") Then
                                    cont = cont + 1
                                    prom = prom + val(Replace(Nota, ",", "."))
                                End If
                                If Me.opt_final_parcial(0) Then
                            
                                'si ramo es ingles
                                'AQUI SAQUE
                                If inglesvar = 1 And val(Ngrado) >= 1 And val(Ngrado) <= 4 And CodModalidad = "110" Then
                                    'imprime promedio lenguaje
                                    Printer.CurrentY = 4500
                                    Printer.CurrentX = 10700
                                    
                                    
                                    If numperiodo = 1 Then
                                        inglesprom = promleng / tnotasl
                                    Else
                                        inglesprom = (promleng + inglesprom) / (tnotasl + 3)
                                    End If
                                    
                                    'inglesprom = (promleng + inglesprom) / (tnotasl + 3)
                                    c_n = inglesprom '(Mid(especial_prom / 3, 1, 3))
                                    sw = 1
                                    
                                    If Len(inglesprom) > 1 Then
                                        Printer.Print (Mid(inglesprom, 1, 1)) & "," & (Mid(inglesprom, 2, 1))
                                    Else
                                        Printer.Print inglesprom & ",0"
                                    End If
                            
                                Else
                                    'si lenguaje
                                    If cole = "ALT001" And val(Sector) = 14 And val(Codasi) = 14 And val(Ngrado) >= 1 And val(Ngrado) <= 4 And CodModalidad = "110" Then
                                    Else
                                        If especial = 1 Then
                                            especial_prom = especial_prom + Nota
                                            especial_promc = especial_promc + pro
                                            contt = contt + 1
                                        Else
                                            Printer.Print (Nota) & "    " & (pro)
                                        End If
                                    End If
                                End If
                                    
                                    
                                End If
                        End If
                    Else
                    
                        If Me.opt_final_parcial(0) Then
                        
                        If rsnotas("cod_asi") = 13 Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = 13 and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                Printer.Print ("Ex.") & "     " & (procur)
                            Else
                                'Printer.Print (Nota)
                                'Printer.Print (Promsemestre) & "     " & (procur)
                                      'Printer.Print (Nota)
                                If Promsemestre <> "EX" Then
                                    Printer.Print (Promsemestre) & "     " & (procur)
                                Else
                                    Printer.Print "     " & "     " & (procur)
                                End If
                            End If
                        Else
                            'Printer.Print (Nota)
                            Printer.Print (Promsemestre) & "     " & (procur)
                        End If
                        
                            'Printer.Print (Promsemestre) & "     " & (procur)
                        End If
                        
                        
                        'imprime naturales
                        
                        
                        If posy <> 0 Then
'                            var_sql = "select MID(p1, 1, 1) AS p1,MID(p1, 3, 1) AS p11,MID(p2, 1, 1) AS p2,MID(p2, 3, 1) AS p22 from promedios where (cod_sec = 3) AND (cod_asi = 5) and ci_alu = '" _
'                            & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" _
'                            & Letra & "' and agno = " & Cmb_Agno.Text & " order by cod_sec, cod_asi"
'                            objRS.Open var_sql, conn
'                            Printer.CurrentY = posy
'                            Printer.CurrentX = 3300 + 400
'                            If numperiodo = 0 Then
'                                Printer.Print objRS("p1") & "," & objRS("p11")
'                            Else
'                                If objRS("p2") & "," & objRS("p22") <> "0,0" Then
'                                Printer.Print objRS("p2") & "," & objRS("p22")
'                                End If
'                            End If
'                            objRS.Close
                            
'                            var_sql = "select MID(p1, 1, 1) AS p1,MID(p1, 3, 1) AS p11,MID(p2, 1, 1) AS p2,MID(p2, 3, 1) AS p22 from promedios where (cod_sec = 3) AND (cod_asi = 6) and ci_alu = '" & rutalumno _
'                            & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & Letra _
'                            & "' and agno = " & Cmb_Agno.Text & " order by cod_sec, cod_asi"
'                            objRS.Open var_sql, conn
'                            Printer.CurrentY = posy
'                            Printer.CurrentX = 3300 + 400 + 400
'                            If numperiodo = 0 Then
'                                Printer.Print objRS("p1") & "," & objRS("p11")
'                            Else
'                                If objRS("p2") & "," & objRS("p22") <> "0,0" Then
'                                Printer.Print objRS("p2") & "," & objRS("p22")
'                                End If
'                            End If
'                            objRS.Close
                            
'                            var_sql = "select MID(p1, 1, 1) AS p1,MID(p1, 3, 1) AS p11,MID(p2, 1, 1) AS p2,MID(p2, 3, 1) AS p22 from promedios where (cod_sec = 3) AND (cod_asi = 7) and ci_alu = '" & rutalumno _
'                            & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & Letra _
'                            & "' and agno = " & Cmb_Agno.Text & " order by cod_sec, cod_asi"
'                            objRS.Open var_sql, conn
'                            Printer.CurrentY = posy
'                            Printer.CurrentX = 3300 + 400 + 400 + 400
'                            If numperiodo = 0 Then
'                                Printer.Print objRS("p1") & "," & objRS("p11")
'                            Else
'                                If objRS("p2") & "," & objRS("p22") <> "0,0" Then
'                                Printer.Print objRS("p2") & "," & objRS("p22")
'                                End If
'                            End If
'                            objRS.Close
'
                        
                            Printer.CurrentY = posy
                            Printer.CurrentX = posx
                        If Ngrado = 7 Or Ngrado = 8 Then
                            If Len(Mid(especial_prom / 3, 1, 3)) <> 1 Then
                                'Mid(especial_prom / 3, 1, 3)
                                'Printer.Print (Mid(especial_prom / 3, 1, 3)) & "    " & (Mid(especial_promc / 3, 1, 3))
                                If especial_prom <> 0 Then
                                Printer.Print (Mid(especial_prom / contt, 1, 3)) & "    " & (Mid(especial_promc / contt, 1, 3))
                                End If
                                c_n = (Mid(especial_prom / contt, 1, 3))
                                sw = 1
                            Else
                                'Printer.Print (Mid(especial_prom / 3, 1, 3)) & ",0    " & (Mid(especial_promc / 3, 1, 3))
                                If especial_prom <> 0 Then
                                Printer.Print (Mid(especial_prom / contt, 1, 3)) & ",0    " & (Mid(especial_promc / contt, 1, 3))
                                End If
                                If especial_prom = 0 And contt = 0 Then
                                    c_n = 0
                                Else
                                    c_n = (Mid(especial_prom / contt, 1, 3))
                                End If
                                
                                sw = 1
                            End If
                        End If
                        End If
                           
                        
                    End If
                    Printer.FontBold = False
                    
                End If

                rsnotas.Close
                RsAux.MoveNext
            Wend
                     
                                    
            Printer.Line (3660, 3900)-(3650, y1 + 400)   '**Linea vertical primera para notas**
            Printer.Line (10600, 3900)-(10600, y1 + 400) '**Linea vertical separador promedio notas**
            Printer.Line (11050, 3900)-(11050, y1 + 400) '**Linea vertical separador promedio curso**
            
            For y2 = 1 To 17
                Printer.Line (3660 + (408 * y2), 3900)-(3660 + (408 * y2), y1 + 400) '**Linea vertical separador notas**
            Next y2

        'ultimo rcuadro
            y1 = y1 + 400 'toma valor de y y se separa
            Printer.Line (50, CLng(y1 + 100))-(11500, CLng(y1 + 500)), , B 'RECUADRO PROMEDIO FINAL
            Printer.CurrentY = y1 + 250
            
'            Printer.CurrentX = 1000
'            Printer.Print "PORCENTAJE ASISTENCIA" ' Porcentaje assitencia
            
            Printer.CurrentX = 8000
            Printer.FontSize = 8
            Printer.Print "PROMEDIO FINAL DEL PERIODO" ' Imprimo asignatura
            Printer.CurrentY = y1 + 250
            Printer.CurrentX = 10950
            Dim NotaFinalInf As String
            If cont <> 0 Then
                If sw = 1 Then
                    If val(Ngrado) >= 1 And val(Ngrado) <= 4 And CodModalidad = "110" Then
                    c_n = c_n / 10
                    End If
                    
                    prom = prom + c_n
                    cont = cont + 1
                End If
                
                NotaFinalInf = Trim(str(prom / cont))
                
            End If
            NotaFinalInf = Mid(NotaFinalInf, 1, 1) & "," & val(Mid(NotaFinalInf, 3, 1))
            If val(NotaFinalInf) < 4 Then
                Printer.FontBold = True
            Else
                Printer.FontBold = False
            End If
            If Me.opt_final_parcial(0) Then
                'Printer.Print (NotaFinalInf)
                If NotaFinalInf <> ",0" Then
                    Printer.Print (NotaFinalInf)
                End If
            End If
            Printer.FontBold = False
    End If
    RsAux.Close
    
    Printer.CurrentY = y1 + 600
    Printer.CurrentX = 100
    'Printer.Print "Nota: El subsector estudio y comprension de la naturalez comprende los promedios de biologia fisica y quimica"
    
    If val(Ngrado) >= 7 And val(Ngrado) <= 8 And CodModalidad = "110" Then
        'Printer.Print "NOTA: EL SUBSECTOR ESTUDIO Y COMPRENSIÓN DE LA NATURALEZA COMPRENDE LOS PROMEDIOS DE BIOLOGÍA, FÍSICA Y QUÍMICA."
    End If
    
'TALLERES CURRICULARES
    var_sql = "select * from talleres where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and tipo_tall = 1"
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
    
        y1 = y1 + 500
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 100
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print ("T A L L E R E S    C U R R I C U L A R E S")
        Printer.FontBold = False

        rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
        
            ydeproceso = ydeproceso + 400
            y3 = y1 + 400
            While Not RsAux.EOF
                y1 = y1 + 400
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 400)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
   
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 400
                Printer.CurrentY = Y4 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 400
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
         
                    For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0"))
                        End If 'sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        Printer.Print (Nota)
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                                      
                rsnotas.Open var_sql, conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If (numperiodo + 1) = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                
                'prefunta primer ciclo MODIFICAR
                'If (CodModalidad <> 110) And (Ngrado <> 1 And Ngrado <> 2 And Ngrado <> 3 And Ngrado <> 4) Then
                    Printer.Print (Promsemestre)
                'End If
                'fin pregunta primer ciclo
                
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If

                rsnotas.Close
                RsAux.MoveNext
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 400)   'linea vertical
            Printer.Line (10600, CInt(y3))-(10600, y1 + 400) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 400) 'linea vertical
            Next y2
    End If
    RsAux.Close
    
    var_sql = "select * from talleres t,alumnos_talleres at" _
            & " where at.ci_alu = '" & rutalumno & "' and t.cod_ens = at.cod_ens" _
            & " and t.cod_tall = at.cod_tall" _
            & " and t.num_gra = at.numgra and t.tipo_tall = at.tipo_tall" _
            & " and at.let_cur = '" & letra & "' and at.cod_ens = '" & CodModalidad & "'" _
            & " and at.numgra = '" & Ngrado & "' and t.tipo_tall = 2 and agno = " & cmb_agno.Text
            
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
        y1 = y1 + 400
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 200
    
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print "T A L L E R E S    L I B R E    ELECCIÓN"
        Printer.FontBold = False

        rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
            ydeproceso = ydeproceso + 400
            y3 = y1 + 400
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 400)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
                      
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = Y4 'Donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 400
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
                    
            For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0")) 'Round(CDec(Val(Nota * 1.01)), 1) ' aqui debo dejar un numero entero 4 como 4,0
                        End If ' sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        Printer.Print (Nota)
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                              
                rsnotas.Open var_sql, conn
            If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If numperiodo + 1 = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                    Printer.Print (Promsemestre)
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If
                rsnotas.Close
                RsAux.MoveNext
               
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 400) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 400) 'linea vertical
            Next y2
            Printer.Line (10600, CInt(y3))-(10600, y1 + 400)
    End If
    RsAux.Close
    
'TALLERES CURRICULARES

End Function

Sub imprimepiepant_hue(Rut_ALu As String, posicion As Integer, CodModalidad As String, Ngrado As String, letra As String)
'Necesito saber el codigo de la modalidad el nivel y la letra para
'imprimir el nombre del profesor jefe.
Dim I As Single, linea1 As Single, linea2 As Single
Dim var_sql As String
Dim encargado As String

'Aqui empieza a dibujarse todo lo que viene después de las notas
'El 7000 es donde empieza el cuadrado con la información del pie de la página
I = 12000 + 400 'Esta variable indica la posición de donde se empezará a dibujar

Printer.FontSize = 8
Printer.CurrentX = 200: Printer.CurrentY = I + 1200: Printer.Print ("OBSERVACIONES")
Printer.Line (200 + Printer.TextWidth("OBSERVACIONES") + 100, I + 1350)-(11500, I + 1350)
Printer.Line (200, I + 1650)-(11500, I + 1650)

'Rescatando rut del profesor
RutProfe = DevuelveCampo("cursos", "", "rut_prof", "agno=" & cmb_agno.Text & " and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'", conn)
cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
'Rescatando nombre completo y horario del profesor

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select noms_prof, ape1_prof, ape2_prof, hor_ate_prof from profesores where rut_prof = '" & RutProfe & "'", conn
If rs.RecordCount Then
    nombreprofe = rs("noms_prof")
    ape1profe = rs("ape1_prof")
    ape2profe = rs("ape2_prof")
    horario = rs("hor_ate_prof")
End If
rs.Close

'var_sql = "select num_gra,cod_ens from alu_x_cur where agno = " & cmb_agno & " and ci_alu = '" & rut_alu & "'"
'rs.Open var_sql, conn

encargado = DevuelveCampo("principal", "", "nombre", "nivel = " & Ngrado & " AND codigo_ensenanza = '" & CodModalidad & "'", conn)

'If cole = "HUE001" Then
'
'    If rs("cod_ens") = "110" And rs("num_gra") >= 1 And rs("num_gra") <= 2 Then
'        encargado = "XIMENA LOÉZAR"
'    End If
'    If rs("cod_ens") = "110" And rs("num_gra") >= 3 And rs("num_gra") <= 6 Then
'        encargado = "XIMENA LOÉZAR"
'    End If
'    If rs("cod_ens") = "110" And rs("num_gra") >= 7 And rs("num_gra") <= 8 Then
'        encargado = "CARLOS NAGEL"
'    End If
'    If rs("cod_ens") = "310" And rs("num_gra") >= 1 Then
'        encargado = "CARLOS NAGEL"
'    End If
'
'Else
'
'    If rs("cod_ens") = "110" And rs("num_gra") >= 1 And rs("num_gra") <= 2 Then
'        encargado = "CLAUDIA RIVERA"
'    End If
'    If rs("cod_ens") = "110" And rs("num_gra") >= 3 And rs("num_gra") <= 4 Then
'        encargado = "CLAUDIA RIVERA"
'    End If
'    If rs("cod_ens") = "110" And rs("num_gra") >= 5 And rs("num_gra") <= 8 Then
'        encargado = "CECILIA TORRES"
'    End If
'    If rs("cod_ens") = "310" And rs("num_gra") >= 1 Then
'        encargado = "CECILIA TORRES"
'    End If
'End If

'rs.Close

Nombreprofejefe = nombreprofe & " " & ape1profe & " " & ape2profe
Cargo1 = "PROFESOR(A) JEFE"
Nombredirec = Nombredir & " " & ape1dir & " " & ape2dir
Nombredirec = encargado
Cargo2 = "COORDINADORA ACADÉMICA"
    mitad = (Printer.ScaleWidth / 2) / 2
    largotexto = Printer.TextWidth(Nombreprofejefe)
    linea1 = mitad - (largotexto / 2)
    Printer.Line (linea1, I + 2300)-(linea1 + Printer.TextWidth(Nombreprofejefe), I + 2300)      'linea de firma del profesor jefe
    Printer.CurrentX = linea1: Printer.CurrentY = I + 2350: Printer.Print (Nombreprofejefe)
    largotexto = Printer.TextWidth(Cargo1) 'Calculo la posicion del cargo del profe
    linea1 = mitad - (largotexto / 2)
    Printer.CurrentX = linea1: Printer.CurrentY = I + 2500: Printer.Print (Cargo1)
'***************************************************************************************
    mitad = (Printer.ScaleWidth / 2) / 2
    largotexto = Printer.TextWidth(Nombredirec)
    linea2 = mitad - (largotexto / 2) + (Printer.ScaleWidth / 2)
    Printer.Line (linea2, I + 2300)-(linea2 + Printer.TextWidth(Nombredirec), I + 2300)      ' linea de firma de la directora
    Printer.CurrentX = linea2: Printer.CurrentY = I + 2350: Printer.Print (Nombredirec)
    largotexto = Printer.TextWidth(Cargo2)
    linea2 = mitad - (largotexto / 2) + (Printer.ScaleWidth / 2)
    Printer.CurrentX = linea2: Printer.CurrentY = I + 2500: Printer.Print (Cargo2)
End Sub


Private Function ImprimeInformeFinal_tall_SBDO(ByVal Rutalu As String, tipo_EVA As Integer, Optional ByVal Medio As String = "impr") As Integer
Dim Str_QueryInforme As String
Dim curso As String
Dim Nom_Asi, Nom_Eva, Str_Notas, Nota As String
Dim BordeH, I, c, StartY, TamCdr, Aumento, Int_NumNotas, Int_NumProm As Integer
Dim Dbl_Nota, Dbl_PromPond, Dbl_Pond, Dbl_SumPromFinal As Double
'Dim pn_b As Double
'Dim pn_f As Double
'Dim pn_q As Double
Dim prom_natu As Double
Dim cont_natu As Integer
Dim prom_natu2 As Double
Dim cont_natu2 As Integer
Dim prom_natu_1 As Double
Dim prom_natu_2 As Double
Dim prom_final_natu As Double

Dim var_sql As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset

cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
    
    'Busco curso para ciencias
    curso = UCase(DevuelveCampo("alu_x_cur", "", "concat(cod_ens,num_gra) ", "agno = " & cmb_agno.Text & " and ci_alu = '" & Rutalu & "' and activo_alu = 'SI'", conn))
    If opt_indiv_gral(1).Value Then
        'Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        If curso = "3101" Then
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' AND " _
                             & "n.tipo_eva = X.tipo_eva AND n.tipo_eva = " & tipo_EVA & " and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        Else
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' AND n.tipo_eva = X.tipo_eva AND n.tipo_eva = " & tipo_EVA _
                             & " and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        End If
    Else
        If curso = "3101" Then
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' AND n.tipo_eva = X.tipo_eva AND n.tipo_eva = " & tipo_EVA _
                             & " and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        Else
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' AND n.tipo_eva = X.tipo_eva AND n.tipo_eva = " & tipo_EVA _
                             & " and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        End If
    End If
    
    BordeH = 13950
    StartY = 2350
    TamCdr = 450
    tamcdr2 = 250
    RsAux.CursorLocation = adUseClient
    RsAux.Open Str_QueryInforme, conn
    'Si esta vacio salgo y no imprimo
    If (RsAux.EOF = True) Then
        Log_AddAnotacion "Inf. Notas Final - Alumno RUN " & Rutalu & "con problemas de consistencia.", True
        Printer.CurrentX = 1000: Printer.CurrentY = StartY + 200: Printer.Print "Alumno Con Errores, tiene información coherente."
        StartY = 2350
        ImprimeInformeFinal_tall_SBDO = CInt(StartY) + 600
        RsAux.Close
        Exit Function
    End If
    '####
    RsAux.MoveFirst
    I = 0
    Int_NumProm = 0
    Dbl_SumPromFinal = 0
    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_asi")
        
        'Modificar cuadrado asignatura
'        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'            Printer.Line (250, StartY + (i * TamCdr))-(BordeH, StartY + ((i + 1) * TamCdr)), , B ' recuadro de la asignatura
'        Else
            Printer.Line (50, StartY + (I * TamCdr))-(BordeH, StartY + ((I + 1) * TamCdr)), , B ' recuadro de la asignatura
        'End If
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * TamCdr))-(3200, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Calific 1 sem
            'Printer.Line (7000, StartY + (i * TamCdr))-(7000, StartY + ((i + 1) * TamCdr)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * TamCdr))-(7630, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * TamCdr))-(8260, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio calific 2 sem
            'Printer.Line (12060, StartY + (i * TamCdr))-(12060, StartY + ((i + 1) * TamCdr)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * TamCdr))-(12690, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * TamCdr))-(13320, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Prom Final
        End If
        'Cambiar posicion nombre asignatura
'        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'            Printer.CurrentX = 300: Printer.CurrentY = StartY + (i * TamCdr) + 50: Printer.Print (Nom_Asi)
'        Else
            Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * TamCdr) + 50: Printer.Print (Nom_Asi)
       ' End If
        If (Nom_Asi = RsAux("nom_asi")) Then
            Nom_Eva = RsAux("des_eva")
            ' Modificar tipo evaluacion y porcentaje
'            If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'                Printer.CurrentX = 550: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Nom_Eva)
'                Printer.CurrentX = 2000: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
'            Else
                Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Nom_Eva)
                Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            'End If
            ' EXIMIDO???
            '''''' Promedio primer semestre naturales
            If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
            Else
'                If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'                       ''''''''''posicion ciencias naturales
'                       If RsAux!cod_asi = 6 Then
'                            posicion_y = StartY + (i * TamCdr) + 200
'                            '''''Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Format("6,8", "0.0"))
'                            If cont_natu > 0 Then
'                                'Biologia
'                                If pn_b <> "" And pn_b <> " " And pn_b <> "  " Then
'                                    prom_natu = prom_natu + (pn_b / 10)
'                                    cont_natu = cont_natu + 1
'                                End If
'                                'Fisica
'                                If pn_f <> "" And pn_f <> " " And pn_f <> "  " Then
'                                    prom_natu = prom_natu + (pn_f / 10)
'                                    cont_natu = cont_natu + 1
'                                End If
'                                'Quimica
'                                If pn_q <> "" And pn_q <> " " And pn_q <> "  " Then
'                                    prom_natu = prom_natu + (pn_q / 10)
'                                    cont_natu = cont_natu + 1
'                                End If
'                                If cole = "SNB001" Then
'                                    If Mid(RsAux("nota"), 25, 2) = "  " Or Mid(RsAux("nota"), 25, 2) = " " Or Mid(RsAux("nota"), 25, 2) = "" Then
'                                        Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
'                                        prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
'                                    Else
'                                        prom_natu_1 = CDbl(Mid((Mid((prom_natu / cont_natu), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
'                                        Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_1)
'                                    End If
'                                Else
'                                    Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
'                                    prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
'                                End If
'                            End If
'                       End If
'
'                Else
                    Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
'                End If
            End If
            
            Str_Notas = RsAux("nota")
            c = 0
            Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            sw = False
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    ' Promedio ciencias primer semestre
'                    If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'                        prom_natu = prom_natu + Dbl_Nota
'                        cont_natu = cont_natu + 1
'                        If RsAux!cod_asi = 3 Then pn_b = Mid(RsAux("nota"), 21, 2)
'                        If RsAux!cod_asi = 7 Then pn_f = Mid(RsAux("nota"), 21, 2)
'                        If RsAux!cod_asi = 8 Then pn_q = Mid(RsAux("nota"), 21, 2)
'                    Else
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
'                    End If
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            End If
            'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec
            If (Nom_Asi = RsAux("nom_asi") And Nom_Eva = RsAux("des_eva")) Then
                ' EXIMIDO???
                '''''Promedio segundo semestre naturales
                If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                Else
'                    If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'                       '''''' Posicion Naturales Semestre
'                       If RsAux!cod_asi = 6 Then
'                            posicion_y = StartY + (i * TamCdr) + 200
'                            ''''''Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Format("6,9", "0.0"))
'                            If cont_natu > 0 Then
''                                If pn_b2 <> "" Then
''                                    prom_natu2 = prom_natu2 + (pn_b2 / 10) + (pn_f2 / 10) + (pn_q2 / 10)
''                                    cont_natu2 = cont_natu2 + 3
''                                End If
'                                 If cont_natu > 0 Then
'                                'Biologia
'                                If pn_b2 <> "" And pn_b2 <> " " And pn_b2 <> "  " Then
'                                    prom_natu2 = prom_natu2 + (pn_b2 / 10)
'                                    cont_natu2 = cont_natu2 + 1
'                                End If
'                                'Fisica
'                                If pn_f2 <> "" And pn_f2 <> " " And pn_f2 <> "  " Then
'                                    prom_natu2 = prom_natu2 + (pn_f2 / 10)
'                                    cont_natu2 = cont_natu2 + 1
'                                End If
'                                'Quimica
'                                If pn_q2 <> "" And pn_q2 <> " " And pn_q2 <> "  " Then
'                                    prom_natu2 = prom_natu2 + (pn_q2 / 10)
'                                    cont_natu2 = cont_natu2 + 1
'                                End If
'                                ''''''''''''Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
'                                ''''''''''''prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
'                                If cole = "SNB001" Then
''                                    prom_natu_1 = CDbl(Mid((Mid((prom_natu / cont_natu), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
''                                    Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_1)
'                                Else
''                                    Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
''                                    prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
'                                End If
'                            End If
''''''''                                Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
''''''''                                prom_natu_2 = Mid((prom_natu2 / cont_natu2), 1, 3)
'                                If cole = "SNB001" Then
'                                    If Mid(RsAux("nota"), 25, 2) = "" Or Mid(RsAux("nota"), 25, 2) = " " Or Mid(RsAux("nota"), 25, 2) = "  " Then
'                                        Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
'                                        prom_natu_2 = Mid((prom_natu2 / cont_natu2), 1, 3)
'                                    Else
'                                        prom_natu_2 = CDbl(Mid((Mid((prom_natu2 / cont_natu2), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
'                                        Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_2)
'                                    End If
'                                Else
'                                    Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
'                                    prom_natu_2 = Mid((prom_natu2 / cont_natu2), 1, 3)
'                                End If
'                            End If
'                       End If
'                    Else
                       
                                        
                       Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
'                    End If
                End If
                ' prom final
                If (RsAux("cod_asi") <> 13 And val(RsAux("promedio_final")) <> 0) And (RsAux("cod_asi") <> 22 And val(RsAux("promedio_final")) <> 0) Then
                    'If (RsAux("cod_asi") <> 22 And val(RsAux("promedio_final")) <> 0) Then
                        If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                        Else
                            ''''''''Columna promedio final informe notas
'                            If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'                                '''''''Promedio Final Ciencias Naturales
'                                If RsAux!cod_asi = 6 Then
'                                    posicion_y = StartY + (i * TamCdr) + 200
'                                    '''''Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format("7,0", "0.0"))
'                                    Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2) / 2), "0.0"))
'                                End If
'                            Else
                            Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                            Int_NumProm = Int_NumProm + 1
                            Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio_final"), "0.0"))
'                            End If
                        End If
                    'End If
                ElseIf RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                    ' Esta EXIMIDO!
                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                Else
                    Select Case CSng(RsAux("promedio_final"))
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
'                    If (RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'                        'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format("7,0", "0.0"))
'                        ''''''''' Promedio Final
'                        Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2) / 2), "0.0"))
'                        prom_final_natu = Format(((prom_natu_1 + prom_natu_2) / 2), "0.0")
'                    Else
                        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print Promsemestre
'                    End If
                    
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                             ' Promedio ciencias segundo semestre
'                        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And RsAux!Num_Gra = 1) Then
'                            prom_natu2 = prom_natu2 + Dbl_Nota
'                            cont_natu2 = cont_natu2 + 1
'                            If RsAux!cod_asi = 3 Then pn_b2 = Mid(RsAux("nota"), 21, 2)
'                            If RsAux!cod_asi = 7 Then pn_f2 = Mid(RsAux("nota"), 21, 2)
'                            If RsAux!cod_asi = 8 Then pn_q2 = Mid(RsAux("nota"), 21, 2)
'                        Else
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
'                        End If
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                   End If
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec
                If (Nom_Asi = RsAux("nom_asi")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                      End If
                    '#########################
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec
                    If (Nom_Asi = RsAux("nom_asi") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        '#########################
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec:
        I = I + 1
SigSubSecEx:
    Wend
    
    var_sql = "select valor from cfg where param = 'CODBC'"
    objRS.Open var_sql, conn
    'If objRS("valor") = "PUD001" And lst_periodos.Text = "ANUAL" Then
    If lst_periodos.Text = "ANUAL" Then
     
        Printer.FontSize = 8: Printer.FontBold = True
        Dim colegio As String
        Dim Sw_Lincoln As Integer
        colegio = UCase(DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn))
        Sw_Lincoln = InStr(1, colegio, "LINCOLN")
        If Not (Sw_Lincoln > 0) Then
            If prom_final_natu > 0 Then
                Dbl_SumPromFinal = (Dbl_SumPromFinal + prom_final_natu) / (Int_NumProm + 1)
            Else
                Dbl_SumPromFinal = Dbl_SumPromFinal / Int_NumProm
            End If
        Else
            Dbl_SumPromFinal = (Fix(((Dbl_SumPromFinal / Int_NumProm) + 0.05) * 10)) / 10
        End If
        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 150: Printer.Print (Format(Dbl_SumPromFinal, "0.0"))
    'Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr) + 500: Printer.Print (devuelvecampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & Cmb_Agno.Text, conn))
   ' Printer.FontSize = 6: Printer.FontBold = False
        RsAux.Close
    
   ' dibujo el cuadrado para situacion final
    Posi = StartY + (I * TamCdr)
    BordeH = 13950
    'Printer.FontSize = 6: Printer.FontBold = False
    
    Printer.FontSize = 6: 'Printer.FontBold = True
    Printer.FontSize = 7
    Printer.FontBold = True
    Printer.CurrentX = 12200: Printer.CurrentY = Posi + 30: Printer.Print ("PROMEDIO")
    Printer.CurrentX = 12200: Printer.CurrentY = Posi + 180: Printer.Print ("FINAL ANUAL")
  '  Printer.FontSize = 6:
    Printer.FontSize = 6: Printer.FontBold = False
   ' Printer.FontSize = 6: Printer.FontBold = False

'    Printer.Line (50, Posi)-(50, Posi + 400)
'    Printer.Line (50, Posi)-(BordeH, Posi)
'    Printer.Line (BordeH, Posi)-(BordeH, Posi + 400)
'    Printer.Line (50, Posi + 400)-(BordeH, Posi + 400)
            
    Printer.Line (12060, Posi + 400)-(BordeH, Posi + 400)
    Printer.Line (BordeH, Posi)-(BordeH, Posi + 400)
    
    If Me.chk_lineasverticales.Value = 0 Then
    Printer.Line (12060, Posi)-(12060, Posi + 400) ' linea vertical separacion promedio semestral
    Printer.Line (13320, Posi)-(13320, Posi + 400) ' linea vertical separacion promedio anual
    End If
    
    j = (TamCdr * I) / 300
    dife = (TamCdr * I) - (tamcdr2 * j)

    Printer.CurrentY = Printer.CurrentY + 1200
    StartY = StartY + 600 + dife
    I = j
    
    
    
    'Talleres

    var_sql = "select p.agno,axc.ci_alu, axc.cod_ens,axc.num_gra,axc.let_cur,t.cod_tall,t.nom_tall,nt.num_per," _
            & "pe.des_per,0 as cod_eva,'APRENDIZAJE' as 'des_eva',100 as 'porcentaje_eva',nt.nota, if(nt.num_per=1,p.p1,p.p2) as promedio," _
            & "round((p.p1+p.p2)/2) as promedio_final" _
            & " from alu_x_cur axc,notas_talleres nt,promedios_talleres p,talleres t,periodos pe" _
            & " where axc.agno = " & cmb_agno.Text _
            & " and axc.ci_alu = '" & Rutalu & "' and axc.activo_alu = 'SI'" _
            & " and axc.cod_ens = nt.cod_ens and axc.num_gra = nt.num_gra" _
            & " and axc.let_cur = nt.let_cur and axc.ci_alu = nt.ci_alu and axc.agno = nt.agno and" _
            & " nt.Cod_Ens = p.Cod_Ens And nt.Num_Gra = p.Num_Gra And nt.Let_Cur = p.Let_Cur And nt.ci_alu = p.ci_alu" _
            & " and nt.agno = p.agno and nt.cod_tall = p.cod_tall and nt.tipo_tall = p.tipo_tall and" _
            & " p.cod_tall = t.cod_tall and p.cod_ens = t.cod_ens and p.num_gra = t.num_gra and t.tipo_tall = p.tipo_tall and t.tipo_tall = 1 and" _
            & "(nt.num_per-1) = pe.num_per"

    RsAux.CursorLocation = adUseClient
    RsAux.Open var_sql, conn

    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_tall")

        Printer.Line (50, StartY + (I * tamcdr2))-(BordeH, StartY + ((I + 1) * tamcdr2)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * tamcdr2))-(3200, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Calific 1 sem
            'Printer.Line (7000, StartY + (i * TamCdr2))-(7000, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * tamcdr2))-(7630, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * tamcdr2))-(8260, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio calific 2 sem
            'Printer.Line (12060, StartY + (i * TamCdr2))-(12060, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * tamcdr2))-(12690, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * tamcdr2))-(13320, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * tamcdr2) + 50 + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_tall")) Then
            Nom_Eva = RsAux("des_eva")
'            Printer.CurrentX = 250: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Nom_Eva)
'            Printer.CurrentX = 2000: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            ' EXIMIDO???
            'If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
            '    Printer.CurrentX = 7730: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
            'Else
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
            'End If

            Str_Notas = RsAux("nota")
            c = 0
                                   Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            End If
            'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec2
            If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                ' EXIMIDO???
                'If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
                    'Printer.CurrentX = 12790: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
                'Else
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
                'End If
                ' prom final
                If (val(RsAux("promedio_final")) <> 0) Then
                   ' If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
                   ' Else
                   
'                   var_sql = "SELECT round((p1+p2)/2) as prome" _
'                           & " From promedios_talleres" _
'                           & " where cod_ens = '" & RsAux("cod_ens") _
'                           & "' and num_gra = " & RsAux("num_gra") & " and let_cur = '" & RsAux("let_cur") _
'                           & "' and agno = " & RsAux("agno") _
'                           & " and  cod_tall = '" & RsAux("cod_tall") _
'                           & "' and ci_alu = '" & RsAux("ci_alu") & "' and tipo_tall = 1"
'                   REC.Open var_sql, conn
'                   prome = REC("prome")
'                   REC.Close
                   
                    Select Case CSng(RsAux("promedio_final") / 10)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                    Int_NumProm = Int_NumProm + 1
                        
                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print Promsemestre ' (Format(RsAux("promedio_final"), "0.0"))
                    'End If
'                ElseIf RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
'                    ' Esta EXIMIDO!
'                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
                'Else
                 '   Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print Format(RsAux("promedio_final"), "0.0")
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                    'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                End If
                'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec2
                If (Nom_Asi = RsAux("nom_tall")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        Printer.CurrentX = 7100: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    '#########################
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec2
                    If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec2
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec2:
        I = I + 1
'SigSubSecEx:
    Wend
    RsAux.Close

    'Talleres Electivos

    var_sql = "select axc.ci_alu, axc.cod_ens,axc.num_gra,axc.let_cur,t.cod_tall,t.nom_tall,nt.num_per," _
            & "pe.des_per,0 as cod_eva,'APRENDIZAJE' as 'des_eva',100 as 'porcentaje_eva',nt.nota, if(nt.num_per=1,p.p1,p.p2) as promedio," _
            & "round((p.p1+p.p2)/2) as promedio_final" _
            & " from alu_x_cur axc,notas_talleres nt,promedios_talleres p,talleres t,periodos pe" _
            & " where axc.agno = " & cmb_agno.Text _
            & " and axc.ci_alu = '" & Rutalu & "' and axc.activo_alu = 'SI'" _
            & " and axc.cod_ens = nt.cod_ens and axc.num_gra = nt.num_gra" _
            & " and axc.let_cur = nt.let_cur and axc.ci_alu = nt.ci_alu and axc.agno = nt.agno and" _
            & " nt.Cod_Ens = p.Cod_Ens And nt.Num_Gra = p.Num_Gra And nt.Let_Cur = p.Let_Cur And nt.ci_alu = p.ci_alu" _
            & " and nt.agno = p.agno and nt.cod_tall = p.cod_tall and nt.tipo_tall = p.tipo_tall and" _
            & " p.cod_tall = t.cod_tall and p.cod_ens = t.cod_ens and p.num_gra = t.num_gra and t.tipo_tall = p.tipo_tall and t.tipo_tall = 2 and" _
            & "(nt.num_per-1) = pe.num_per"

    RsAux.CursorLocation = adUseClient
    RsAux.Open var_sql, conn

    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_tall")

        Printer.Line (50, StartY + (I * tamcdr2))-(BordeH, StartY + ((I + 1) * tamcdr2)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * tamcdr2))-(3200, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Calific 1 sem
            'Printer.Line (7000, StartY + (i * TamCdr2))-(7000, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * tamcdr2))-(7630, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * tamcdr2))-(8260, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio calific 2 sem
            'Printer.Line (12060, StartY + (i * TamCdr2))-(12060, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * tamcdr2))-(12690, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * tamcdr2))-(13320, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * tamcdr2) + 50 + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_tall")) Then
            Nom_Eva = RsAux("des_eva")
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
            Str_Notas = RsAux("nota")
            c = 0
                                   Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
            End If
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec3
            If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
                If val(RsAux("promedio_final")) <> 0 Then

                   Select Case CSng(RsAux("promedio_final") / 10)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                        Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                        Int_NumProm = Int_NumProm + 1
                        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print Promsemestre '(Format(RsAux("promedio_final"), "0.0"))
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                End If
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec3
                If (Nom_Asi = RsAux("nom_tall")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec3
                    If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        '#########################
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec3
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec3:
        I = I + 1
'SigSubSecEx:
    Wend
    ImprimeInformeFinal_tall_SBDO = StartY + (I * tamcdr2)
    objRS.Close
    RsAux.Close
 Else
    
    Printer.FontSize = 8: Printer.FontBold = True
    colegio = UCase(DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn))
    Sw_Lincoln = InStr(1, colegio, "LINCOLN")
    If Not (Sw_Lincoln > 0) Then
        Dbl_SumPromFinal = Dbl_SumPromFinal / Int_NumProm
    Else
        Dbl_SumPromFinal = (Fix((Dbl_SumPromFinal / Int_NumProm) * 10)) / 10
    End If
    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * tamcdr2) + 150: Printer.Print (Format(Dbl_SumPromFinal, "0.0"))
    Printer.FontSize = 6: Printer.FontBold = False
    RsAux.Close
    ImprimeInformeFinal_tall_SBDO = StartY + (I * tamcdr2)
    objRS.Close
End If
End Function



Private Function ImprimeInformeFinal_tall(ByVal Rutalu As String, Optional ByVal Medio As String = "impr") As Integer
Dim Str_QueryInforme As String
Dim curso As String
Dim Nom_Asi, Nom_Eva, Str_Notas, Nota As String
Dim BordeH, I, c, StartY, TamCdr, Aumento, Int_NumNotas, Int_NumProm As Integer
Dim Dbl_Nota, Dbl_PromPond, Dbl_Pond, Dbl_SumPromFinal As Double
'Dim pn_b As Double
'Dim pn_f As Double
'Dim pn_q As Double
Dim prom_natu As Double
Dim cont_natu As Integer
Dim prom_natu2 As Double
Dim cont_natu2 As Integer
Dim prom_natu_1 As Double
Dim prom_natu_2 As Double
Dim prom_final_natu As Double

Dim var_sql As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset

cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
    
    'Busco curso para ciencias
    curso = UCase(DevuelveCampo("alu_x_cur", "", "concat(cod_ens,num_gra) ", "agno = " & cmb_agno.Text & " and ci_alu = '" & Rutalu & "' and activo_alu = 'SI'", conn))
    If opt_indiv_gral(1).Value Then
        'Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        If curso = "3101" Or curso = "3102" Then
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        Else
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        End If
    Else
        If curso = "3101" Or curso = "3102" Then
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        Else
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        End If
    End If
    
    BordeH = 13950
    StartY = 2350
    TamCdr = 450
    tamcdr2 = 250
    RsAux.CursorLocation = adUseClient
    RsAux.Open Str_QueryInforme, conn
    'Si esta vacio salgo y no imprimo
    If (RsAux.EOF = True) Then
        Log_AddAnotacion "Inf. Notas Final - Alumno RUN " & Rutalu & "con problemas de consistencia.", True
        Printer.CurrentX = 1000: Printer.CurrentY = StartY + 200: Printer.Print "Alumno Con Errores, tiene información coherente."
        ImprimeInformeFinal_tall = StartY + 600
        RsAux.Close
        Exit Function
    End If
    '####
    RsAux.MoveFirst
    I = 0
    Int_NumProm = 0
    Dbl_SumPromFinal = 0
    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_asi")
        
        'Modificar cuadrado asignatura
        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
            Printer.Line (250, StartY + (I * TamCdr))-(BordeH, StartY + ((I + 1) * TamCdr)), , B ' recuadro de la asignatura
        Else
            Printer.Line (50, StartY + (I * TamCdr))-(BordeH, StartY + ((I + 1) * TamCdr)), , B ' recuadro de la asignatura
        End If
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * TamCdr))-(3200, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Calific 1 sem
            'Printer.Line (7000, StartY + (i * TamCdr))-(7000, StartY + ((i + 1) * TamCdr)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * TamCdr))-(7630, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * TamCdr))-(8260, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio calific 2 sem
            'Printer.Line (12060, StartY + (i * TamCdr))-(12060, StartY + ((i + 1) * TamCdr)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * TamCdr))-(12690, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * TamCdr))-(13320, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Prom Final
        End If
        'Cambiar posicion nombre asignatura
        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
            Printer.CurrentX = 300: Printer.CurrentY = StartY + (I * TamCdr) + 50: Printer.Print (Nom_Asi)
        Else
            Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * TamCdr) + 50: Printer.Print (Nom_Asi)
        End If
        If (Nom_Asi = RsAux("nom_asi")) Then
            Nom_Eva = RsAux("des_eva")
            ' Modificar tipo evaluacion y porcentaje
            If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                Printer.CurrentX = 550: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Nom_Eva)
                Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            Else
                Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Nom_Eva)
                Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            End If
            ' EXIMIDO???
            '''''' Promedio primer semestre naturales
            If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi='" & RsAux!cod_asi & "' and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
            Else
                If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                       ''''''''''posicion ciencias naturales
                       If RsAux!cod_asi = 6 Then
                            posicion_y = StartY + (I * TamCdr) + 200
                            '''''Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Format("6,8", "0.0"))
                            If cont_natu > 0 Then
                                'Biologia
                                If pn_b <> "" And pn_b <> " " And pn_b <> "  " Then
                                    prom_natu = prom_natu + (pn_b / 10)
                                    cont_natu = cont_natu + 1
                                End If
                                'Fisica
                                If pn_f <> "" And pn_f <> " " And pn_f <> "  " Then
                                    prom_natu = prom_natu + (pn_f / 10)
                                    cont_natu = cont_natu + 1
                                End If
                                'Quimica
                                If pn_q <> "" And pn_q <> " " And pn_q <> "  " Then
                                    prom_natu = prom_natu + (pn_q / 10)
                                    cont_natu = cont_natu + 1
                                End If
                                If cole = "SNB001" Then
                                    If Mid(RsAux("nota"), 25, 2) = "  " Or Mid(RsAux("nota"), 25, 2) = " " Or Mid(RsAux("nota"), 25, 2) = "" Then
                                        Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
                                        prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
                                    Else
                                        prom_natu_1 = CDbl(Mid((Mid((prom_natu / cont_natu), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
                                        Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_1)
                                    End If
                                Else
                                    Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print Format((Mid((prom_natu / cont_natu) + 0.04, 1, 3)), "0.0")
                                    'prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
                                    prom_natu_1 = Mid((prom_natu / cont_natu) + 0.04, 1, 3)
                                End If
                            End If
                       End If

                Else
                    Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                End If
            End If
            
            Str_Notas = RsAux("nota")
            c = 0
            Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            sw = False
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    ' Promedio ciencias primer semestre
                    If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                        prom_natu = prom_natu + Dbl_Nota
                        cont_natu = cont_natu + 1
                        If RsAux!cod_asi = 3 Then pn_b = Mid(RsAux("nota"), 21, 2)
                        If RsAux!cod_asi = 7 Then pn_f = Mid(RsAux("nota"), 21, 2)
                        If RsAux!cod_asi = 8 Then pn_q = Mid(RsAux("nota"), 21, 2)
                        If tot_notas = 10 Then
                                pn = DevuelveCampo("subsectores", "", "pn", "cod_asi = '" & RsAux!cod_asi & "' and cod_ens ='" & RsAux!Cod_Ens & "' and num_gra ='" & RsAux!Num_Gra & "'", conn)
                                If pn = 1 Then
                                    prom_natu2 = prom_natu2 + Dbl_Nota
                                    cont_natu2 = cont_natu2 + 1
                                    If RsAux!cod_asi = 3 Then pn_b2 = Mid(RsAux("nota"), 21, 2)
                                    If RsAux!cod_asi = 7 Then pn_f2 = Mid(RsAux("nota"), 21, 2)
                                    If RsAux!cod_asi = 8 Then pn_q2 = Mid(RsAux("nota"), 21, 2)
                                End If
                        End If
                    Else
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    End If
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            End If
            'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec
            If (Nom_Asi = RsAux("nom_asi") And Nom_Eva = RsAux("des_eva")) Then
                ' EXIMIDO???
                '''''Promedio segundo semestre naturales
                If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi='" & RsAux!cod_asi & "' and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                Else
                    If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                       '''''' Posicion Naturales Semestre
                       If RsAux!cod_asi = 6 Then
                            posicion_y = StartY + (I * TamCdr) + 200
                            ''''''Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Format("6,9", "0.0"))
                            If cont_natu2 > 0 Then
'                                If pn_b2 <> "" Then
'                                    prom_natu2 = prom_natu2 + (pn_b2 / 10) + (pn_f2 / 10) + (pn_q2 / 10)
'                                    cont_natu2 = cont_natu2 + 3
'                                End If
                                 If cont_natu > 0 Then
                                'Biologia
                                If pn_b2 <> "" And pn_b2 <> " " And pn_b2 <> "  " Then
                                    prom_natu2 = prom_natu2 + (pn_b2 / 10)
                                    cont_natu2 = cont_natu2 + 1
                                End If
                                'Fisica
                                If pn_f2 <> "" And pn_f2 <> " " And pn_f2 <> "  " Then
                                    prom_natu2 = prom_natu2 + (pn_f2 / 10)
                                    cont_natu2 = cont_natu2 + 1
                                End If
                                'Quimica
                                If pn_q2 <> "" And pn_q2 <> " " And pn_q2 <> "  " Then
                                    prom_natu2 = prom_natu2 + (pn_q2 / 10)
                                    cont_natu2 = cont_natu2 + 1
                                End If
                                ''''''''''''Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
                                ''''''''''''prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
                                If cole = "SNB001" Then
'                                    prom_natu_1 = CDbl(Mid((Mid((prom_natu / cont_natu), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
'                                    Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_1)
                                Else
'                                    Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
'                                    prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
                                End If
                            End If
'''''''                                Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
'''''''                                prom_natu_2 = Mid((prom_natu2 / cont_natu2), 1, 3)
                                If cole = "SNB001" Then
                                    If Mid(RsAux("nota"), 25, 2) = "" Or Mid(RsAux("nota"), 25, 2) = " " Or Mid(RsAux("nota"), 25, 2) = "  " Then
                                        Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
                                        prom_natu_2 = Mid((prom_natu2 / cont_natu2), 1, 3)
                                    Else
                                        prom_natu_2 = CDbl(Mid((Mid((prom_natu2 / cont_natu2), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
                                        Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_2)
                                    End If
                                Else
                                    Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print Format((Mid((prom_natu2 / cont_natu2) + 0.04, 1, 3)), "0.0")
                                    prom_natu_2 = Mid((prom_natu2 / cont_natu2) + 0.04, 1, 3)
                                End If
                            End If
                       End If
                    Else
                       
                                        
                       Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                    End If
                End If
                ' prom final
                If (RsAux("cod_asi") <> 13 And val(RsAux("promedio_final")) <> 0) And (RsAux("cod_asi") <> 22 And val(RsAux("promedio_final")) <> 0) Then
                    'If (RsAux("cod_asi") <> 22 And val(RsAux("promedio_final")) <> 0) Then
                        If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi='" & RsAux!cod_asi & "' and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                        Else
                            ''''''''Columna promedio final informe notas
                            If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                                '''''''Promedio Final Ciencias Naturales
                                If RsAux!cod_asi = 6 Then
                                    posicion_y = StartY + (I * TamCdr) + 200
                                    '''''Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format("7,0", "0.0"))
                                    Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2) / 2), "0.0"))
                                End If
                            Else
                            Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                            Int_NumProm = Int_NumProm + 1
                            Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio_final"), "0.0"))
                            End If
                        End If
                    'End If
                ElseIf RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                    ' Esta EXIMIDO!
                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                Else
                    Select Case CSng(RsAux("promedio_final"))
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If (RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                        'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format("7,0", "0.0"))
                        ''''''''' Promedio Final
                        '''Si los 2 semestres tienen nota
                        If prom_natu_1 > 0 And prom_natu_2 > 0 Then
                            Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2) / 2), "0.0"))
                            prom_final_natu = Format(((prom_natu_1 + prom_natu_2) / 2), "0.0")
                        ElseIf prom_natu_1 > 0 And prom_natu_2 = 0 Then
                            Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_1, "0.0"))
                            prom_final_natu = Format(prom_natu_1, "0.0")
                        ElseIf prom_natu_1 = 0 And prom_natu_2 > 1 Then
                            Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_2, "0.0"))
                            prom_final_natu = Format(prom_natu_2, "0.0")
                        End If
                    Else
                        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print Promsemestre
                    End If
                    
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                             ' Promedio ciencias segundo semestre
                        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                            prom_natu2 = prom_natu2 + Dbl_Nota
                            cont_natu2 = cont_natu2 + 1
                            If RsAux!cod_asi = 3 Then pn_b2 = Mid(RsAux("nota"), 21, 2)
                            If RsAux!cod_asi = 7 Then pn_f2 = Mid(RsAux("nota"), 21, 2)
                            If RsAux!cod_asi = 8 Then pn_q2 = Mid(RsAux("nota"), 21, 2)
                            If tot_notas = 10 Then
                                pn = DevuelveCampo("subsectores", "", "pn", "cod_asi = '" & RsAux!cod_asi & "' and cod_ens ='" & RsAux!Cod_Ens & "' and num_gra ='" & RsAux!Num_Gra & "'", conn)
                                If pn = 1 Then
                                    prom_natu2 = prom_natu2 + Dbl_Nota
                                    cont_natu2 = cont_natu2 + 1
                                    If RsAux!cod_asi = 3 Then pn_b2 = Mid(RsAux("nota"), 21, 2)
                                    If RsAux!cod_asi = 7 Then pn_f2 = Mid(RsAux("nota"), 21, 2)
                                    If RsAux!cod_asi = 8 Then pn_q2 = Mid(RsAux("nota"), 21, 2)
                                End If
                            End If
                        Else
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        End If
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                   End If
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec
                If (Nom_Asi = RsAux("nom_asi")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                      End If
                    '#########################
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec
                    If (Nom_Asi = RsAux("nom_asi") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * TamCdr) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        '#########################
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec:
        I = I + 1
SigSubSecEx:
    Wend
    
    var_sql = "select valor from cfg where param = 'CODBC'"
    objRS.Open var_sql, conn
    'If objRS("valor") = "PUD001" And lst_periodos.Text = "ANUAL" Then
    If lst_periodos.Text = "ANUAL" Then
     
        Printer.FontSize = 8: Printer.FontBold = True
        Dim colegio As String
        Dim Sw_Lincoln As Integer
        colegio = UCase(DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn))
        Sw_Lincoln = 0 'InStr(1, colegio, "LINCOLN")
        If Not (Sw_Lincoln > 0) Then
            If prom_final_natu > 0 Then
                Dbl_SumPromFinal = (Dbl_SumPromFinal + prom_final_natu) / (Int_NumProm + 1)
            Else
                Dbl_SumPromFinal = Dbl_SumPromFinal / Int_NumProm
            End If
        Else
            Dbl_SumPromFinal = (Fix((Dbl_SumPromFinal / Int_NumProm) * 10)) / 10
        End If
        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * TamCdr) + 150: Printer.Print (Format(Dbl_SumPromFinal, "0.0"))
    'Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr) + 500: Printer.Print (devuelvecampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & Cmb_Agno.Text, conn))
   ' Printer.FontSize = 6: Printer.FontBold = False
        RsAux.Close
    
   ' dibujo el cuadrado para situacion final
    Posi = StartY + (I * TamCdr)
    BordeH = 13950
    'Printer.FontSize = 6: Printer.FontBold = False
    
    Printer.FontSize = 6: 'Printer.FontBold = True
    Printer.FontSize = 7
    Printer.FontBold = True
    Printer.CurrentX = 12200: Printer.CurrentY = Posi + 30: Printer.Print ("PROMEDIO")
    Printer.CurrentX = 12200: Printer.CurrentY = Posi + 180: Printer.Print ("FINAL ANUAL")
  '  Printer.FontSize = 6:
    Printer.FontSize = 6: Printer.FontBold = False
   ' Printer.FontSize = 6: Printer.FontBold = False

'    Printer.Line (50, Posi)-(50, Posi + 400)
'    Printer.Line (50, Posi)-(BordeH, Posi)
'    Printer.Line (BordeH, Posi)-(BordeH, Posi + 400)
'    Printer.Line (50, Posi + 400)-(BordeH, Posi + 400)
            
    Printer.Line (12060, Posi + 400)-(BordeH, Posi + 400)
    Printer.Line (BordeH, Posi)-(BordeH, Posi + 400)
    
    If Me.chk_lineasverticales.Value = 0 Then
    Printer.Line (12060, Posi)-(12060, Posi + 400) ' linea vertical separacion promedio semestral
    Printer.Line (13320, Posi)-(13320, Posi + 400) ' linea vertical separacion promedio anual
    End If
    
    j = (TamCdr * I) / 300
    dife = (TamCdr * I) - (tamcdr2 * j)

    Printer.CurrentY = Printer.CurrentY + 1200
    StartY = StartY + 600 + dife
    I = j
    
    
    
    'Talleres

    var_sql = "select p.agno,axc.ci_alu, axc.cod_ens,axc.num_gra,axc.let_cur,t.cod_tall,t.nom_tall,nt.num_per," _
            & "pe.des_per,0 as cod_eva,'APRENDIZAJE' as 'des_eva',100 as 'porcentaje_eva',nt.nota, if(nt.num_per=1,p.p1,p.p2) as promedio," _
            & "round((p.p1+p.p2)/2) as promedio_final" _
            & " from alu_x_cur axc,notas_talleres nt,promedios_talleres p,talleres t,periodos pe" _
            & " where axc.agno = " & cmb_agno.Text _
            & " and axc.ci_alu = '" & Rutalu & "' and axc.activo_alu = 'SI'" _
            & " and axc.cod_ens = nt.cod_ens and axc.num_gra = nt.num_gra" _
            & " and axc.let_cur = nt.let_cur and axc.ci_alu = nt.ci_alu and axc.agno = nt.agno and" _
            & " nt.Cod_Ens = p.Cod_Ens And nt.Num_Gra = p.Num_Gra And nt.Let_Cur = p.Let_Cur And nt.ci_alu = p.ci_alu" _
            & " and nt.agno = p.agno and nt.cod_tall = p.cod_tall and nt.tipo_tall = p.tipo_tall and" _
            & " p.cod_tall = t.cod_tall and p.cod_ens = t.cod_ens and p.num_gra = t.num_gra and t.tipo_tall = p.tipo_tall and t.tipo_tall = 1 and" _
            & "(nt.num_per-1) = pe.num_per"

    RsAux.CursorLocation = adUseClient
    RsAux.Open var_sql, conn

    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_tall")

        Printer.Line (50, StartY + (I * tamcdr2))-(BordeH, StartY + ((I + 1) * tamcdr2)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * tamcdr2))-(3200, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Calific 1 sem
            'Printer.Line (7000, StartY + (i * TamCdr2))-(7000, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * tamcdr2))-(7630, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * tamcdr2))-(8260, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio calific 2 sem
            'Printer.Line (12060, StartY + (i * TamCdr2))-(12060, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * tamcdr2))-(12690, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * tamcdr2))-(13320, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * tamcdr2) + 50 + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_tall")) Then
            Nom_Eva = RsAux("des_eva")
'            Printer.CurrentX = 250: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Nom_Eva)
'            Printer.CurrentX = 2000: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            ' EXIMIDO???
            'If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
            '    Printer.CurrentX = 7730: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
            'Else
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
            'End If

            Str_Notas = RsAux("nota")
            c = 0
                                   Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            End If
            'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec2
            If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                ' EXIMIDO???
                'If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
                    'Printer.CurrentX = 12790: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
                'Else
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
                'End If
                ' prom final
                If (val(RsAux("promedio_final")) <> 0) Then
                   ' If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
                   ' Else
                   
'                   var_sql = "SELECT round((p1+p2)/2) as prome" _
'                           & " From promedios_talleres" _
'                           & " where cod_ens = '" & RsAux("cod_ens") _
'                           & "' and num_gra = " & RsAux("num_gra") & " and let_cur = '" & RsAux("let_cur") _
'                           & "' and agno = " & RsAux("agno") _
'                           & " and  cod_tall = '" & RsAux("cod_tall") _
'                           & "' and ci_alu = '" & RsAux("ci_alu") & "' and tipo_tall = 1"
'                   REC.Open var_sql, conn
'                   prome = REC("prome")
'                   REC.Close
                   
                    Select Case CSng(RsAux("promedio_final") / 10)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                    Int_NumProm = Int_NumProm + 1
                        
                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print Promsemestre ' (Format(RsAux("promedio_final"), "0.0"))
                    'End If
'                ElseIf RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
'                    ' Esta EXIMIDO!
'                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
                'Else
                 '   Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print Format(RsAux("promedio_final"), "0.0")
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                    'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                End If
                'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec2
                If (Nom_Asi = RsAux("nom_tall")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        Printer.CurrentX = 7100: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    '#########################
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec2
                    If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec2
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec2:
        I = I + 1
'SigSubSecEx:
    Wend
    RsAux.Close

    'Talleres Electivos

    var_sql = "select axc.ci_alu, axc.cod_ens,axc.num_gra,axc.let_cur,t.cod_tall,t.nom_tall,nt.num_per," _
            & "pe.des_per,0 as cod_eva,'APRENDIZAJE' as 'des_eva',100 as 'porcentaje_eva',nt.nota, if(nt.num_per=1,p.p1,p.p2) as promedio," _
            & "round((p.p1+p.p2)/2) as promedio_final" _
            & " from alu_x_cur axc,notas_talleres nt,promedios_talleres p,talleres t,periodos pe" _
            & " where axc.agno = " & cmb_agno.Text _
            & " and axc.ci_alu = '" & Rutalu & "' and axc.activo_alu = 'SI'" _
            & " and axc.cod_ens = nt.cod_ens and axc.num_gra = nt.num_gra" _
            & " and axc.let_cur = nt.let_cur and axc.ci_alu = nt.ci_alu and axc.agno = nt.agno and" _
            & " nt.Cod_Ens = p.Cod_Ens And nt.Num_Gra = p.Num_Gra And nt.Let_Cur = p.Let_Cur And nt.ci_alu = p.ci_alu" _
            & " and nt.agno = p.agno and nt.cod_tall = p.cod_tall and nt.tipo_tall = p.tipo_tall and" _
            & " p.cod_tall = t.cod_tall and p.cod_ens = t.cod_ens and p.num_gra = t.num_gra and t.tipo_tall = p.tipo_tall and t.tipo_tall = 2 and" _
            & "(nt.num_per-1) = pe.num_per"

    RsAux.CursorLocation = adUseClient
    RsAux.Open var_sql, conn

    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_tall")

        Printer.Line (50, StartY + (I * tamcdr2))-(BordeH, StartY + ((I + 1) * tamcdr2)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * tamcdr2))-(3200, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Calific 1 sem
            'Printer.Line (7000, StartY + (i * TamCdr2))-(7000, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * tamcdr2))-(7630, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * tamcdr2))-(8260, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio calific 2 sem
            'Printer.Line (12060, StartY + (i * TamCdr2))-(12060, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * tamcdr2))-(12690, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * tamcdr2))-(13320, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * tamcdr2) + 50 + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_tall")) Then
            Nom_Eva = RsAux("des_eva")
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
            Str_Notas = RsAux("nota")
            c = 0
                                   Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
            End If
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec3
            If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
                If val(RsAux("promedio_final")) <> 0 Then

                   Select Case CSng(RsAux("promedio_final") / 10)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                        Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                        Int_NumProm = Int_NumProm + 1
                        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print Promsemestre '(Format(RsAux("promedio_final"), "0.0"))
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                End If
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec3
                If (Nom_Asi = RsAux("nom_tall")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec3
                    If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        '#########################
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec3
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec3:
        I = I + 1
'SigSubSecEx:
    Wend
    ImprimeInformeFinal_tall = StartY + (I * tamcdr2)
    objRS.Close
    RsAux.Close
 Else
    
    Printer.FontSize = 8: Printer.FontBold = True
    colegio = UCase(DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn))
    Sw_Lincoln = InStr(1, colegio, "LINCOLN")
    If Not (Sw_Lincoln > 0) Then
        Dbl_SumPromFinal = Dbl_SumPromFinal / Int_NumProm
    Else
        Dbl_SumPromFinal = (Fix((Dbl_SumPromFinal / Int_NumProm) * 10)) / 10
    End If
    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * tamcdr2) + 150: Printer.Print (Format(Dbl_SumPromFinal, "0.0"))
    Printer.FontSize = 6: Printer.FontBold = False
    RsAux.Close
    ImprimeInformeFinal_tall = StartY + (I * tamcdr2)
    objRS.Close
End If
End Function


Private Function ImprimeInformeFinal_tall_tri(ByVal Rutalu As String, Optional ByVal Medio As String = "impr") As Integer
Dim Str_QueryInforme As String
Dim curso As String
Dim Nom_Asi, Nom_Eva, Str_Notas, Nota As String
Dim BordeH, I, c, StartY, TamCdr, Aumento, Int_NumNotas, Int_NumProm As Integer
Dim Dbl_Nota, Dbl_PromPond, Dbl_Pond, Dbl_SumPromFinal As Double
'Dim pn_b As Double
'Dim pn_f As Double
'Dim pn_q As Double
Dim prom_natu As Double
Dim cont_natu As Integer
Dim prom_natu2 As Double
Dim cont_natu2 As Integer
Dim prom_natu3 As Double
Dim cont_natu3 As Integer
Dim prom_natu_1 As Double
Dim prom_natu_2 As Double
Dim prom_natu_3 As Double
Dim prom_final_natu As Double

Dim var_sql As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset

cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
    
    'Busco curso para ciencias
    curso = UCase(DevuelveCampo("alu_x_cur", "", "concat(cod_ens,num_gra) ", "agno = " & cmb_agno.Text & " and ci_alu = '" & Rutalu & "' and activo_alu = 'SI'", conn))
    If opt_indiv_gral(1).Value Then
        'Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, if(n.num_per=0, x.p1, x.p2) as promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        If curso = "3101" Or curso = "3102" Then
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, IF(n.num_per=0,X.p1,IF(n.num_per=1,X.p2,X.p3)) AS promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos_trimestral p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        Else
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, IF(n.num_per=0,X.p1,IF(n.num_per=1,X.p2,X.p3)) AS promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos_trimestral p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        End If
    Else
        If curso = "3101" Or curso = "3102" Then
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, IF(n.num_per=0,X.p1,IF(n.num_per=1,X.p2,X.p3)) AS promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos_trimestral p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        Else
            Str_QueryInforme = "select axc.ci_alu, axc.cod_ens, axc.num_gra, axc.let_cur, s.cod_asi, s.nom_asi, s.ord_asi, n.num_per, p.des_per, n.cod_eva, e.des_eva, e.porcentaje_eva, n.nota, IF(n.num_per=0,X.p1,IF(n.num_per=1,X.p2,X.p3)) AS promedio, x.nf as promedio_final from alu_x_cur axc, notas n, subsectores s, periodos_trimestral p, promedios x, evaluaciones e where axc.activo_alu = 'SI' and nf <> '0.0' and axc.fec_cam='1111-11-11' and axc.ci_alu=n.ci_alu and axc.cod_ens=n.cod_ens and axc.num_gra=n.num_gra and axc.let_cur=n.letra_curso and n.cod_asi=s.cod_asi and n.cod_sec=s.cod_sec and n.cod_ens=s.cod_ens and n.num_gra=s.num_gra and n.num_per=p.num_per and x.ci_alu=axc.ci_alu and axc.cod_ens=x.cod_ens and axc.num_gra=x.num_gra and axc.let_cur=x.letra_curso and n.cod_sec=x.cod_sec and n.cod_asi=x.cod_asi and n.cod_eva=e.cod_eva and s.ord_asi<>0 and axc.ci_alu='" & Rutalu & "' and n.agno=" & cmb_agno.Text & " and n.agno=x.agno and n.agno=axc.agno Order by s.ord_asi, s.cod_asi, n.cod_eva, n.num_per;"
        End If
    End If
    
    'BordeH = 13950
    BordeH = 14100
    StartY = 2350
    TamCdr = 350
    tamcdr2 = 150
    RsAux.CursorLocation = adUseClient
    RsAux.Open Str_QueryInforme, conn
    'Si esta vacio salgo y no imprimo
    If (RsAux.EOF = True) Then
        Log_AddAnotacion "Inf. Notas Final - Alumno RUN " & Rutalu & "con problemas de consistencia.", True
        Printer.CurrentX = 1000: Printer.CurrentY = StartY + 200: Printer.Print "Alumno Con Errores, tiene información coherente."
        ImprimeInformeFinal_tall_tri = StartY + 600
        RsAux.Close
        Exit Function
    End If
    '####
    RsAux.MoveFirst
    I = 0
    Int_NumProm = 0
    Dbl_SumPromFinal = 0
    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_asi")
        
        'Modificar cuadrado asignatura
        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
            Printer.Line (250, StartY + (I * TamCdr))-(BordeH, StartY + ((I + 1) * TamCdr)), , B ' recuadro de la asignatura
        Else
            Printer.Line (50, StartY + (I * TamCdr))-(BordeH, StartY + ((I + 1) * TamCdr)), , B ' recuadro de la asignatura
        End If
        If Me.chk_lineasverticales.Value = 0 Then
            
            Printer.Line (2200, StartY + (I * TamCdr))-(2200, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Calific 1 sem
            Printer.Line (5430, StartY + (I * TamCdr))-(5430, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom periodo
            Printer.Line (6000, StartY + (I * TamCdr))-(6000, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio calific 2 sem
            Printer.Line (9190, StartY + (I * TamCdr))-(9190, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom per 2 sem
            Printer.Line (9770, StartY + (I * TamCdr))-(9770, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Prom Final
            Printer.Line (12960, StartY + (I * TamCdr))-(12960, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13530, StartY + (I * TamCdr))-(13530, StartY + ((I + 1) * TamCdr)) ' linea vertical inicio Prom Final
            
        End If
        'Cambiar posicion nombre asignatura
        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
            Printer.CurrentX = 300: Printer.CurrentY = StartY + (I * TamCdr) + 50: Printer.Print (Nom_Asi)
        Else
            Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * TamCdr) + 50: Printer.Print (Nom_Asi)
        End If
        If (Nom_Asi = RsAux("nom_asi")) Then
            Nom_Eva = RsAux("des_eva")
            ' Modificar tipo evaluacion y porcentaje
            If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                'Printer.CurrentX = 550: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Nom_Eva)
                'Printer.CurrentX = 2000: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            Else
                'Printer.CurrentX = 250: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Nom_Eva)
                'Printer.CurrentX = 2000: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            End If
            ' EXIMIDO???
            '''''' Promedio primer semestre naturales
            If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                'Printer.CurrentX = 7730: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print "EX"
                Printer.CurrentX = 5620: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
            Else
                If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                       ''''''''''posicion ciencias naturales
                       If RsAux!cod_asi = 6 Then
                            posicion_y = StartY + (I * TamCdr) + 200
                            '''''Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Format("6,8", "0.0"))
                            If cont_natu > 0 Then
                                'Biologia
                                If pn_b <> "" And pn_b <> " " And pn_b <> "  " Then
                                    prom_natu = prom_natu + (pn_b / 10)
                                    cont_natu = cont_natu + 1
                                End If
                                'Fisica
                                If pn_f <> "" And pn_f <> " " And pn_f <> "  " Then
                                    prom_natu = prom_natu + (pn_f / 10)
                                    cont_natu = cont_natu + 1
                                End If
                                'Quimica
                                If pn_q <> "" And pn_q <> " " And pn_q <> "  " Then
                                    prom_natu = prom_natu + (pn_q / 10)
                                    cont_natu = cont_natu + 1
                                End If
                                If cole = "SNB001" Then
                                    If Mid(RsAux("nota"), 25, 2) = "  " Or Mid(RsAux("nota"), 25, 2) = " " Or Mid(RsAux("nota"), 25, 2) = "" Then
                                        'Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
                                        'Printer.CurrentX = 5470: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
                                        Printer.CurrentX = 5620: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
                                        prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
                                    Else
                                        prom_natu_1 = CDbl(Mid((Mid((prom_natu / cont_natu), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
                                        'Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_1)
                                        Printer.CurrentX = 5620: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_1)
                                    End If
                                Else
                                    'Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print Format((Mid((prom_natu / cont_natu) + 0.04, 1, 3)), "0.0")
                                    Printer.CurrentX = 5620: Printer.CurrentY = posicion_y: Printer.Print Format((Mid((prom_natu / cont_natu) + 0.04, 1, 3)), "0.0")
                                    'prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
                                    prom_natu_1 = Mid((prom_natu / cont_natu) + 0.04, 1, 3)
                                End If
                            End If
                       End If

                Else
                    'Printer.CurrentX = 7730: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                    Printer.CurrentX = 5620: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                End If
            End If
            
            Str_Notas = RsAux("nota")
            c = 0
            Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            sw = False
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    ' Promedio ciencias primer semestre
                    If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                        prom_natu = prom_natu + Dbl_Nota
                        cont_natu = cont_natu + 1
                        If RsAux!cod_asi = 3 Then pn_b = Mid(RsAux("nota"), 21, 2)
                        If RsAux!cod_asi = 7 Then pn_f = Mid(RsAux("nota"), 21, 2)
                        If RsAux!cod_asi = 8 Then pn_q = Mid(RsAux("nota"), 21, 2)
                        If tot_notas = 10 Then
                                pn = DevuelveCampo("subsectores", "", "pn", "cod_asi = '" & RsAux!cod_asi & "' and cod_ens ='" & RsAux!Cod_Ens & "' and num_gra ='" & RsAux!Num_Gra & "'", conn)
                                If pn = 1 Then
                                    prom_natu2 = prom_natu2 + Dbl_Nota
                                    cont_natu2 = cont_natu2 + 1
                                    If RsAux!cod_asi = 3 Then pn_b2 = Mid(RsAux("nota"), 21, 2)
                                    If RsAux!cod_asi = 7 Then pn_f2 = Mid(RsAux("nota"), 21, 2)
                                    If RsAux!cod_asi = 8 Then pn_q2 = Mid(RsAux("nota"), 21, 2)
                                End If
                        End If
                    Else
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    End If
                    'Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                    Printer.CurrentX = (2100 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            End If
            'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec
            If (Nom_Asi = RsAux("nom_asi") And Nom_Eva = RsAux("des_eva")) Then
                ' EXIMIDO???
                '''''Promedio segundo semestre naturales
                If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                Else
                    If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                       '''''' Posicion Naturales Semestre
                       If RsAux!cod_asi = 6 Then
                            posicion_y = StartY + (I * TamCdr) + 200
                            ''''''Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Format("6,9", "0.0"))
                            If cont_natu2 > 0 Then
'                                If pn_b2 <> "" Then
'                                    prom_natu2 = prom_natu2 + (pn_b2 / 10) + (pn_f2 / 10) + (pn_q2 / 10)
'                                    cont_natu2 = cont_natu2 + 3
'                                End If
                                 If cont_natu > 0 Then
                                'Biologia
                                If pn_b2 <> "" And pn_b2 <> " " And pn_b2 <> "  " Then
                                    prom_natu2 = prom_natu2 + (pn_b2 / 10)
                                    cont_natu2 = cont_natu2 + 1
                                End If
                                'Fisica
                                If pn_f2 <> "" And pn_f2 <> " " And pn_f2 <> "  " Then
                                    prom_natu2 = prom_natu2 + (pn_f2 / 10)
                                    cont_natu2 = cont_natu2 + 1
                                End If
                                'Quimica
                                If pn_q2 <> "" And pn_q2 <> " " And pn_q2 <> "  " Then
                                    prom_natu2 = prom_natu2 + (pn_q2 / 10)
                                    cont_natu2 = cont_natu2 + 1
                                End If
                                ''''''''''''Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
                                ''''''''''''prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)
                          
                            End If
'''''''                                Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
'''''''                                prom_natu_2 = Mid((prom_natu2 / cont_natu2), 1, 3)
                                If cole = "SNB001" Then
                                    If Mid(RsAux("nota"), 25, 2) = "" Or Mid(RsAux("nota"), 25, 2) = " " Or Mid(RsAux("nota"), 25, 2) = "  " Then
                                        'Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
                                        'Printer.CurrentX = 9300: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
                                        Printer.CurrentX = 9400: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
                                        prom_natu_2 = Mid((prom_natu2 / cont_natu2), 1, 3)
                                    Else
                                        prom_natu_2 = CDbl(Mid((Mid((prom_natu2 / cont_natu2), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
                                        'Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_2)
                                        Printer.CurrentX = 9400: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_2)
                                    End If
                                Else
                                    Printer.CurrentX = 9400: Printer.CurrentY = posicion_y: Printer.Print Format((Mid((prom_natu2 / cont_natu2) + 0.04, 1, 3)), "0.0")
                                    prom_natu_2 = Mid((prom_natu2 / cont_natu2) + 0.04, 1, 3)
                                End If
                            End If
                       End If
                    Else
                       
                                        
                       'Printer.CurrentX = 12790: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                       Printer.CurrentX = 9400: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                    End If
                End If
                ' prom final
                If (RsAux("cod_asi") <> 13 And val(RsAux("promedio_final")) <> 0) And (RsAux("cod_asi") <> 22 And val(RsAux("promedio_final")) <> 0) Then
                    'If (RsAux("cod_asi") <> 22 And val(RsAux("promedio_final")) <> 0) Then
                        If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                        Else
                            ''''''''Columna promedio final informe notas
                            If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                                '''''''Promedio Final Ciencias Naturales
                                If RsAux!cod_asi = 6 Then
                                    posicion_y = StartY + (I * TamCdr) + 200
                                    '''''Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format("7,0", "0.0"))
                                    Printer.CurrentX = 13520: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2 + prom_natu_3) / 3), "0.0"))
                                End If
                            Else
                            Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                            Int_NumProm = Int_NumProm + 1
                            'Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(RsAux("promedio_final"), "0.0"))
                            Printer.CurrentX = 13750: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio_final"), "0.0"))
                            End If
                        End If
                    'End If
                ElseIf RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                    ' Esta EXIMIDO!
                    'Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print "EX"
                    Printer.CurrentX = 13750: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                Else
                    Select Case CSng(RsAux("promedio_final"))
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If (RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                        'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format("7,0", "0.0"))
                        ''''''''' Promedio Final
''''''''''''''                        '''Si los 3 semestres tienen nota
''''''''''''''                        If prom_natu_1 > 0 And prom_natu_2 > 0 And prom_natu_3 > 0 Then
''''''''''''''                            'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2) / 2), "0.0"))
''''''''''''''                            Printer.CurrentX = 13630: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2 + prom_natu_3) / 3), "0.0"))
''''''''''''''                            prom_final_natu = Format(((prom_natu_1 + prom_natu_2 + prom_natu_3) / 3), "0.0")
''''''''''''''                        ElseIf prom_natu_1 > 0 And prom_natu_2 > 0 And prom_natu_3 = 0 Then
''''''''''''''                            Printer.CurrentX = 13630: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2) / 2), "0.0"))
''''''''''''''                            prom_final_natu = Format(((prom_natu_1 + prom_natu_2) / 2), "0.0")
''''''''''''''                        ElseIf prom_natu_1 > 0 And prom_natu_2 = 0 Then
''''''''''''''                            'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_1, "0.0"))
''''''''''''''                            Printer.CurrentX = 13630: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_1, "0.0"))
''''''''''''''                            prom_final_natu = Format(prom_natu_1, "0.0")
''''''''''''''                        ElseIf prom_natu_1 = 0 And prom_natu_2 > 1 Then
''''''''''''''                            'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_2, "0.0"))
''''''''''''''                            Printer.CurrentX = 13630: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_2, "0.0"))
''''''''''''''                            prom_final_natu = Format(prom_natu_2, "0.0")
''''''''''''''                        End If
                    Else
                        'Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print Promsemestre
                        Printer.CurrentX = 13750: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print Promsemestre
                    End If
                    
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                             ' Promedio ciencias segundo semestre
                        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                            prom_natu2 = prom_natu2 + Dbl_Nota
                            cont_natu2 = cont_natu2 + 1
                            If RsAux!cod_asi = 3 Then pn_b2 = Mid(RsAux("nota"), 21, 2)
                            If RsAux!cod_asi = 7 Then pn_f2 = Mid(RsAux("nota"), 21, 2)
                            If RsAux!cod_asi = 8 Then pn_q2 = Mid(RsAux("nota"), 21, 2)
                            If tot_notas = 10 Then
                                pn = DevuelveCampo("subsectores", "", "pn", "cod_asi = '" & RsAux!cod_asi & "' and cod_ens ='" & RsAux!Cod_Ens & "' and num_gra ='" & RsAux!Num_Gra & "'", conn)
                                If pn = 1 Then
                                    prom_natu2 = prom_natu2 + Dbl_Nota
                                    cont_natu2 = cont_natu2 + 1
                                    If RsAux!cod_asi = 3 Then pn_b2 = Mid(RsAux("nota"), 21, 2)
                                    If RsAux!cod_asi = 7 Then pn_f2 = Mid(RsAux("nota"), 21, 2)
                                    If RsAux!cod_asi = 8 Then pn_q2 = Mid(RsAux("nota"), 21, 2)
                                End If
                            End If
                        Else
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        End If
                        'Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                        Printer.CurrentX = (5900 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                   End If
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec
                
                ' inicio guuuud
                'If (RsAux.EOF = True) Then GoTo SigSubSec
                If (Nom_Asi = RsAux("nom_asi") And Nom_Eva = RsAux("des_eva")) Then
                    ' EXIMIDO???
                    '''''Promedio tercer semestre naturales
                    If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & cmb_agno.Text, conn) = RsAux!cod_asi Then
                       Printer.CurrentX = 10650: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print "EX"
                    Else
                        If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8 Or RsAux!cod_asi = 6) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                           '''''' Posicion Naturales Semestre
                           If RsAux!cod_asi = 6 Then
                                posicion_y = StartY + (I * TamCdr) + 200
'                                '''Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Format("6,9", "0.0"))
                             If cont_natu3 > 0 Then

                                    If cont_natu > 0 Then
                                        'Biologia
                                        If pn_b3 <> "" And pn_b2 <> " " And pn_b3 <> "  " Then
                                            prom_natu3 = prom_natu3 + (pn_b3 / 10)
                                            cont_natu3 = cont_natu3 + 1
                                        End If
                                        'Fisica
                                        If pn_f3 <> "" And pn_f3 <> " " And pn_f3 <> "  " Then
                                            prom_natu3 = prom_natu3 + (pn_f3 / 10)
                                            cont_natu3 = cont_natu3 + 1
                                        End If
                                        'Quimica
                                        If pn_q3 <> "" And pn_q3 <> " " And pn_q3 <> "  " Then
                                            prom_natu3 = prom_natu3 + (pn_q3 / 10)
                                            cont_natu3 = cont_natu3 + 1
                                        End If
                                        ''''''''''''Printer.CurrentX = 7730: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu / cont_natu), 1, 3))
                                        ''''''''''''prom_natu_1 = Mid((prom_natu / cont_natu), 1, 3)

                                    End If
'''''                                Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
'''''                                prom_natu_2 = Mid((prom_natu2 / cont_natu2), 1, 3)
                                    If cole = "SNB001" Then
                                            If Mid(RsAux("nota"), 25, 2) = "" Or Mid(RsAux("nota"), 25, 2) = " " Or Mid(RsAux("nota"), 25, 2) = "  " Then
                                                'Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu2 / cont_natu2), 1, 3))
                                                Printer.CurrentX = 13160: Printer.CurrentY = posicion_y: Printer.Print (Mid((prom_natu3 / cont_natu3), 1, 3))
                                                prom_natu_3 = Mid((prom_natu3 / cont_natu3), 1, 3)
                                            Else
                                                prom_natu_3 = CDbl(Mid((Mid((prom_natu3 / cont_natu3), 1, 3) * 0.8), 1, 3)) + CDbl(Mid(((Mid(RsAux("nota"), 25, 2) / 10) * 0.2), 1, 3))
                                                'Printer.CurrentX = 12790: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_2)
                                                Printer.CurrentX = 13160: Printer.CurrentY = posicion_y: Printer.Print (prom_natu_2)
                                            End If
                                    Else
                                            '12990
                                            Printer.CurrentX = 13160: Printer.CurrentY = posicion_y: Printer.Print Format((Mid((prom_natu3 / cont_natu3) + 0.04, 1, 3)), "0.0")
                                            prom_natu_3 = Mid((prom_natu3 / cont_natu3) + 0.04, 1, 3)
                                            
                                            '''Si los 3 semestres tienen nota incluyo promedio aqui
                                            If prom_natu_1 > 0 And prom_natu_2 > 0 And prom_natu_3 > 0 Then
                                                'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2) / 2), "0.0"))
                                                'Printer.CurrentX = 13630: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2 + prom_natu_3) / 3), "0.0"))
                                                Printer.CurrentX = 13750: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2 + prom_natu_3) / 3), "0.0"))
                                                prom_final_natu = Format(((prom_natu_1 + prom_natu_2 + prom_natu_3) / 3), "0.0")
                                            ElseIf prom_natu_1 > 0 And prom_natu_2 > 0 And prom_natu_3 = 0 Then
                                                Printer.CurrentX = 13750: Printer.CurrentY = posicion_y: Printer.Print (Format(((prom_natu_1 + prom_natu_2) / 2), "0.0"))
                                                prom_final_natu = Format(((prom_natu_1 + prom_natu_2) / 2), "0.0")
                                            ElseIf prom_natu_1 > 0 And prom_natu_2 = 0 Then
                                                'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_1, "0.0"))
                                                Printer.CurrentX = 13750: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_1, "0.0"))
                                                prom_final_natu = Format(prom_natu_1, "0.0")
                                            ElseIf prom_natu_1 = 0 And prom_natu_2 > 1 Then
                                                'Printer.CurrentX = 13420: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_2, "0.0"))
                                                Printer.CurrentX = 13750: Printer.CurrentY = posicion_y: Printer.Print (Format(prom_natu_2, "0.0"))
                                                prom_final_natu = Format(prom_natu_2, "0.0")
                                            End If
                                            
                                            
                                            
                                            
                                    End If
                                End If
                             End If
                        
                      Else
'
'
'                      'Printer.CurrentX = 12790: Printer.CurrentY = StartY + (i * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                      Printer.CurrentX = 13160: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(RsAux("promedio"), "0.0"))
                    End If
                    End If
                End If




                ' esto guuuuuuuuuuuuuuuuuuuuud
                If (Nom_Asi = RsAux("nom_asi")) Then
                    Nom_Eva = RsAux("des_eva")

                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            ' Promedio ciencias tercer semestre
                            If (RsAux!cod_asi = 3 Or RsAux!cod_asi = 7 Or RsAux!cod_asi = 8) And (RsAux!Cod_Ens = "310" And (RsAux!Num_Gra = 1 Or RsAux!Num_Gra = 2)) Then
                                prom_natu3 = prom_natu3 + Dbl_Nota
                                cont_natu3 = cont_natu3 + 1
                                If RsAux!cod_asi = 3 Then pn_b3 = Mid(RsAux("nota"), 21, 2)
                                If RsAux!cod_asi = 7 Then pn_f3 = Mid(RsAux("nota"), 21, 2)
                                If RsAux!cod_asi = 8 Then pn_q3 = Mid(RsAux("nota"), 21, 2)
                                If tot_notas = 10 Then
                                    pn = DevuelveCampo("subsectores", "", "pn", "cod_asi = '" & RsAux!cod_asi & "' and cod_ens ='" & RsAux!Cod_Ens & "' and num_gra ='" & RsAux!Num_Gra & "'", conn)
                                    If pn = 1 Then
                                        prom_natu3 = prom_natu3 + Dbl_Nota
                                        cont_natu3 = cont_natu3 + 1
                                        If RsAux!cod_asi = 3 Then pn_b3 = Mid(RsAux("nota"), 21, 2)
                                        If RsAux!cod_asi = 7 Then pn_f3 = Mid(RsAux("nota"), 21, 2)
                                        If RsAux!cod_asi = 8 Then pn_q3 = Mid(RsAux("nota"), 21, 2)
                                    End If
                                End If
                            Else
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        End If
                            'Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (i * TamCdr) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            Printer.CurrentX = (9700 + Aumento): Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                    End If
                    '#########################
                    RsAux.MoveNext

                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec:
        I = I + 1
SigSubSecEx:
    Wend
    
    var_sql = "select valor from cfg where param = 'CODBC'"
    objRS.Open var_sql, conn
    'If objRS("valor") = "PUD001" And lst_periodos.Text = "ANUAL" Then
    If lst_periodos.Text = "ANUAL" Then
     
        Printer.FontSize = 7: Printer.FontBold = True
        Dim colegio As String
        Dim Sw_Lincoln As Integer
        colegio = UCase(DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn))
        Sw_Lincoln = 0 'InStr(1, colegio, "LINCOLN")
        If Not (Sw_Lincoln > 0) Then
            If prom_final_natu > 0 Then
                Dbl_SumPromFinal = (Dbl_SumPromFinal + prom_final_natu) / (Int_NumProm + 1)
            Else
                Dbl_SumPromFinal = Dbl_SumPromFinal / Int_NumProm
            End If
        Else
            Dbl_SumPromFinal = (Fix((Dbl_SumPromFinal / Int_NumProm) * 10)) / 10
        End If
        Printer.CurrentX = 13750: Printer.CurrentY = StartY + (I * TamCdr) + 200: Printer.Print (Format(Dbl_SumPromFinal, "0.0"))
    'Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr) + 500: Printer.Print (devuelvecampo("matriculas", "", "cod_sit", "ci_alu = '" & Rutalu & "' AND anno_mat = " & Cmb_Agno.Text, conn))
   ' Printer.FontSize = 6: Printer.FontBold = False
        RsAux.Close
    
   ' dibujo el cuadrado para situacion final
    Posi = StartY + (I * TamCdr)
    BordeH = 14100
    'Printer.FontSize = 6: Printer.FontBold = False
    
    Printer.FontSize = 6: 'Printer.FontBold = True
    Printer.FontSize = 6
    Printer.FontBold = True
    Printer.CurrentX = 12650: Printer.CurrentY = Posi + 30: Printer.Print ("PROMEDIO")
    Printer.CurrentX = 12650: Printer.CurrentY = Posi + 180: Printer.Print ("FINAL ANUAL")
  '  Printer.FontSize = 6:
    Printer.FontSize = 6: Printer.FontBold = False
   ' Printer.FontSize = 6: Printer.FontBold = False

'    Printer.Line (50, Posi)-(50, Posi + 400)
'    Printer.Line (50, Posi)-(BordeH, Posi)
'    Printer.Line (BordeH, Posi)-(BordeH, Posi + 400)
'    Printer.Line (50, Posi + 400)-(BordeH, Posi + 400)
            
    Printer.Line (12550, Posi + 400)-(BordeH, Posi + 400)
    Printer.Line (BordeH, Posi)-(BordeH, Posi + 400)
    
    If Me.chk_lineasverticales.Value = 0 Then
    Printer.Line (12550, Posi)-(12550, Posi + 400) ' linea vertical separacion promedio semestral
    Printer.Line (13530, Posi)-(13530, Posi + 400) ' linea vertical separacion promedio anual
    End If
    
    j = (TamCdr * I) / 300
    dife = (TamCdr * I) - (tamcdr2 * j)

    Printer.CurrentY = Printer.CurrentY + 1200
    StartY = StartY + 600 + dife
    I = j
    
    
    
    'Talleres

    var_sql = "select p.agno,axc.ci_alu, axc.cod_ens,axc.num_gra,axc.let_cur,t.cod_tall,t.nom_tall,nt.num_per," _
            & "pe.des_per,0 as cod_eva,'APRENDIZAJE' as 'des_eva',100 as 'porcentaje_eva',nt.nota, if(nt.num_per=1,p.p1,p.p2) as promedio," _
            & "round((p.p1+p.p2)/2) as promedio_final" _
            & " from alu_x_cur axc,notas_talleres nt,promedios_talleres p,talleres t,periodos pe" _
            & " where axc.agno = " & cmb_agno.Text _
            & " and axc.ci_alu = '" & Rutalu & "' and axc.activo_alu = 'SI'" _
            & " and axc.cod_ens = nt.cod_ens and axc.num_gra = nt.num_gra" _
            & " and axc.let_cur = nt.let_cur and axc.ci_alu = nt.ci_alu and axc.agno = nt.agno and" _
            & " nt.Cod_Ens = p.Cod_Ens And nt.Num_Gra = p.Num_Gra And nt.Let_Cur = p.Let_Cur And nt.ci_alu = p.ci_alu" _
            & " and nt.agno = p.agno and nt.cod_tall = p.cod_tall and nt.tipo_tall = p.tipo_tall and" _
            & " p.cod_tall = t.cod_tall and p.cod_ens = t.cod_ens and p.num_gra = t.num_gra and t.tipo_tall = p.tipo_tall and t.tipo_tall = 1 and" _
            & "(nt.num_per-1) = pe.num_per"

    RsAux.CursorLocation = adUseClient
    RsAux.Open var_sql, conn

    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_tall")

        Printer.Line (50, StartY + (I * tamcdr2))-(BordeH, StartY + ((I + 1) * tamcdr2)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * tamcdr2))-(3200, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Calific 1 sem
            'Printer.Line (7000, StartY + (i * TamCdr2))-(7000, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * tamcdr2))-(7630, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * tamcdr2))-(8260, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio calific 2 sem
            'Printer.Line (12060, StartY + (i * TamCdr2))-(12060, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * tamcdr2))-(12690, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * tamcdr2))-(13320, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * tamcdr2) + 50 + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_tall")) Then
            Nom_Eva = RsAux("des_eva")
'            Printer.CurrentX = 250: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Nom_Eva)
'            Printer.CurrentX = 2000: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (RsAux("porcentaje_eva") & "%")
            ' EXIMIDO???
            'If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
            '    Printer.CurrentX = 7730: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
            'Else
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
            'End If

            Str_Notas = RsAux("nota")
            c = 0
                                   Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            End If
            'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec2
            If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                ' EXIMIDO???
                'If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
                    'Printer.CurrentX = 12790: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
                'Else
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
                'End If
                ' prom final
                If (val(RsAux("promedio_final")) <> 0) Then
                   ' If RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
                   ' Else
                   
'                   var_sql = "SELECT round((p1+p2)/2) as prome" _
'                           & " From promedios_talleres" _
'                           & " where cod_ens = '" & RsAux("cod_ens") _
'                           & "' and num_gra = " & RsAux("num_gra") & " and let_cur = '" & RsAux("let_cur") _
'                           & "' and agno = " & RsAux("agno") _
'                           & " and  cod_tall = '" & RsAux("cod_tall") _
'                           & "' and ci_alu = '" & RsAux("ci_alu") & "' and tipo_tall = 1"
'                   REC.Open var_sql, conn
'                   prome = REC("prome")
'                   REC.Close
                   
                    Select Case CSng(RsAux("promedio_final") / 10)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                    Int_NumProm = Int_NumProm + 1
                        
                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print Promsemestre ' (Format(RsAux("promedio_final"), "0.0"))
                    'End If
'                ElseIf RetornaCampo("acta_alumexi", "cod_asi", "run_alu='" & Rutalu & "' and cod_asi=" & RsAux!cod_asi & " and agno=" & Cmb_Agno.Text, conn) = RsAux!cod_asi Then
'                    ' Esta EXIMIDO!
'                    Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print "EX"
                'Else
                 '   Printer.CurrentX = 13420: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print Format(RsAux("promedio_final"), "0.0")
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                    'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                End If
                'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 200: Printer.Print (Format(Dbl_PromPond, "0.00"))
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec2
                If (Nom_Asi = RsAux("nom_tall")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        Printer.CurrentX = 7100: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    '#########################
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec2
                    If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            Printer.CurrentX = 12160: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec2
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec2:
        I = I + 1
'SigSubSecEx:
    Wend
    RsAux.Close

    'Talleres Electivos

    var_sql = "select axc.ci_alu, axc.cod_ens,axc.num_gra,axc.let_cur,t.cod_tall,t.nom_tall,nt.num_per," _
            & "pe.des_per,0 as cod_eva,'APRENDIZAJE' as 'des_eva',100 as 'porcentaje_eva',nt.nota, if(nt.num_per=1,p.p1,p.p2) as promedio," _
            & "round((p.p1+p.p2)/2) as promedio_final" _
            & " from alu_x_cur axc,notas_talleres nt,promedios_talleres p,talleres t,periodos pe" _
            & " where axc.agno = " & cmb_agno.Text _
            & " and axc.ci_alu = '" & Rutalu & "' and axc.activo_alu = 'SI'" _
            & " and axc.cod_ens = nt.cod_ens and axc.num_gra = nt.num_gra" _
            & " and axc.let_cur = nt.let_cur and axc.ci_alu = nt.ci_alu and axc.agno = nt.agno and" _
            & " nt.Cod_Ens = p.Cod_Ens And nt.Num_Gra = p.Num_Gra And nt.Let_Cur = p.Let_Cur And nt.ci_alu = p.ci_alu" _
            & " and nt.agno = p.agno and nt.cod_tall = p.cod_tall and nt.tipo_tall = p.tipo_tall and" _
            & " p.cod_tall = t.cod_tall and p.cod_ens = t.cod_ens and p.num_gra = t.num_gra and t.tipo_tall = p.tipo_tall and t.tipo_tall = 2 and" _
            & "(nt.num_per-1) = pe.num_per"

    RsAux.CursorLocation = adUseClient
    RsAux.Open var_sql, conn

    While Not (RsAux.EOF)
        Nom_Asi = RsAux("nom_tall")

        Printer.Line (50, StartY + (I * tamcdr2))-(BordeH, StartY + ((I + 1) * tamcdr2)), , B ' recuadro de la asignatura
        If Me.chk_lineasverticales.Value = 0 Then
            Printer.Line (3200, StartY + (I * tamcdr2))-(3200, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Calific 1 sem
            'Printer.Line (7000, StartY + (i * TamCdr2))-(7000, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom ponderado
            Printer.Line (7630, StartY + (I * tamcdr2))-(7630, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom periodo
            Printer.Line (8260, StartY + (I * tamcdr2))-(8260, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio calific 2 sem
            'Printer.Line (12060, StartY + (i * TamCdr2))-(12060, StartY + ((i + 1) * TamCdr2)) ' linea vertical inicio prom pond 2 sem
            Printer.Line (12690, StartY + (I * tamcdr2))-(12690, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio prom per 2 sem
            Printer.Line (13320, StartY + (I * tamcdr2))-(13320, StartY + ((I + 1) * tamcdr2)) ' linea vertical inicio Prom Final
        End If
        Printer.CurrentX = 100: Printer.CurrentY = StartY + (I * tamcdr2) + 50 + 50: Printer.Print (Nom_Asi)
        If (Nom_Asi = RsAux("nom_tall")) Then
            Nom_Eva = RsAux("des_eva")
                Printer.CurrentX = 7730: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
            Str_Notas = RsAux("nota")
            c = 0
                                   Aumento = 0
            Int_NumNotas = 0
            Dbl_PromPond = 0
            Dbl_Pond = RsAux("porcentaje_eva") / 100
            tot_notas = 0
            While Len(Str_Notas) > 0 And tot_notas < 13
                Aumento = Aumento + 250
                Nota = Left(Str_Notas, 2)
                Str_Notas = Mid(Str_Notas, 3)
                Dbl_Nota = val(Nota) / 10
                If Dbl_Nota <> 0 Then
                    Int_NumNotas = Int_NumNotas + 1
                    Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                    Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                End If
                tot_notas = tot_notas + 1
            Wend
            If Int_NumNotas <> 0 Then
                Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
            End If
            ' #######################
            RsAux.MoveNext
            If (RsAux.EOF = True) Then GoTo SigSubSec3
            If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                    Printer.CurrentX = 12790: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format((RsAux("promedio") / 10), "0.0"))
                If val(RsAux("promedio_final")) <> 0 Then

                   Select Case CSng(RsAux("promedio_final") / 10)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                        Dbl_SumPromFinal = Dbl_SumPromFinal + RsAux("promedio_final")
                        Int_NumProm = Int_NumProm + 1
                        Printer.CurrentX = 13420: Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print Promsemestre '(Format(RsAux("promedio_final"), "0.0"))
                End If
                ' ####
                Str_Notas = RsAux("nota")
                c = 0
                Aumento = 0
                Int_NumNotas = 0
                Dbl_PromPond = 0
                Dbl_Pond = RsAux("porcentaje_eva") / 100
                tot_notas = 0
                While Len(Str_Notas) > 0 And tot_notas < 13
                    Aumento = Aumento + 250
                    Nota = Left(Str_Notas, 2)
                    Str_Notas = Mid(Str_Notas, 3)
                    Dbl_Nota = val(Nota) / 10
                    If Dbl_Nota <> 0 Then
                        Int_NumNotas = Int_NumNotas + 1
                        Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                        Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 100: Printer.Print (Format(Dbl_Nota, "0.0"))
                    End If
                    tot_notas = tot_notas + 1
                Wend
                If Int_NumNotas <> 0 Then
                    Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                End If
                '####################
                RsAux.MoveNext
                If (RsAux.EOF = True) Then GoTo SigSubSec3
                If (Nom_Asi = RsAux("nom_tall")) Then
                    Nom_Eva = RsAux("des_eva")
                    Printer.CurrentX = 250: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Nom_Eva)
                    Printer.CurrentX = 2000: Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (RsAux("porcentaje_eva") & "%")
                    Str_Notas = RsAux("nota")
                    c = 0
                    Aumento = 0
                    Int_NumNotas = 0
                    Dbl_PromPond = 0
                    Dbl_Pond = RsAux("porcentaje_eva") / 100
                    tot_notas = 0
                    While Len(Str_Notas) > 0 And tot_notas < 13
                        Aumento = Aumento + 250
                        Nota = Left(Str_Notas, 2)
                        Str_Notas = Mid(Str_Notas, 3)
                        Dbl_Nota = val(Nota) / 10
                        If Dbl_Nota <> 0 Then
                            Int_NumNotas = Int_NumNotas + 1
                            Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                            Printer.CurrentX = (3110 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                        End If
                        tot_notas = tot_notas + 1
                    Wend
                    If Int_NumNotas <> 0 Then
                        Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                        'Printer.CurrentX = 7100: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                    End If
                    RsAux.MoveNext
                    If (RsAux.EOF = True) Then GoTo SigSubSec3
                    If (Nom_Asi = RsAux("nom_tall") And Nom_Eva = RsAux("des_eva")) Then
                        Str_Notas = RsAux("nota")
                        c = 0
                        Aumento = 0
                        Int_NumNotas = 0
                        Dbl_PromPond = 0
                        Dbl_Pond = RsAux("porcentaje_eva") / 100
                        tot_notas = 0
                        While Len(Str_Notas) > 0 And tot_notas < 13
                            Aumento = Aumento + 250
                            Nota = Left(Str_Notas, 2)
                            Str_Notas = Mid(Str_Notas, 3)
                            Dbl_Nota = val(Nota) / 10
                            If Dbl_Nota <> 0 Then
                                Int_NumNotas = Int_NumNotas + 1
                                Dbl_PromPond = Dbl_PromPond + Dbl_Nota
                                Printer.CurrentX = (8170 + Aumento): Printer.CurrentY = StartY + (I * tamcdr2) + 330: Printer.Print (Format(Dbl_Nota, "0.0"))
                            End If
                            tot_notas = tot_notas + 1
                        Wend
                        If Int_NumNotas <> 0 Then
                            Dbl_PromPond = ((Fix((Dbl_PromPond / Int_NumNotas) * 10)) / 10) * Dbl_Pond
                            'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        End If
                        'Printer.CurrentX = 12160: Printer.CurrentY = StartY + (i * TamCdr2) + 330: Printer.Print (Format(Dbl_PromPond, "0.00"))
                        '#########################
                        RsAux.MoveNext
                        If (RsAux.EOF = True) Then GoTo SigSubSec3
                    Else
                    ' ver el caso
                    End If
                Else
                'ver caso
                End If
            Else
            ' ver caso
            End If
        Else
        ' ver caso
        End If
SigSubSec3:
        I = I + 1
'SigSubSecEx:
    Wend
    ImprimeInformeFinal_tall_tri = StartY + (I * tamcdr2)
    objRS.Close
    RsAux.Close
 Else
    
    Printer.FontSize = 7: Printer.FontBold = True
    colegio = UCase(DevuelveCampo("establecimientos", "", "nom_est", "rdb <> ''", conn))
    Sw_Lincoln = InStr(1, colegio, "LINCOLN")
    If Not (Sw_Lincoln > 0) Then
        Dbl_SumPromFinal = Dbl_SumPromFinal / Int_NumProm
    Else
        Dbl_SumPromFinal = (Fix((Dbl_SumPromFinal / Int_NumProm) * 10)) / 10
    End If
    Printer.CurrentX = 13750: Printer.CurrentY = StartY + (I * tamcdr2) + 200: Printer.Print (Format(Dbl_SumPromFinal, "0.0"))
    Printer.FontSize = 5: Printer.FontBold = False
    RsAux.Close
    ImprimeInformeFinal_tall_tri = StartY + (I * tamcdr2)
    objRS.Close
End If
End Function



Private Sub ImprimeInformeFinalCab_tall(ByVal rutalumno As String, ByVal Ngrado As String, ByVal letra As String, ByVal NombreModalidad)

    Dim BordeH As Integer

    Call EncabezadoInformeFinal(True)
    If Me.opt_final_parcial(0) Then
        Tipoinforme = UCase(Me.opt_final_parcial(0).Caption)
    ElseIf Me.opt_final_parcial(1) Then
        Tipoinforme = UCase(Me.opt_final_parcial(1).Caption)
    End If
    BordeH = 13950
    Printer.FontSize = 9
    Call centrarenpapel(1000, Tipoinforme & " " & Me.lst_periodos.Text & " " & cmb_agno.Text)  ' Este año debe ser el de proceso NO DEL SISTEMA
    ' ACABO DE IMPRIMIR EL TITULO CENTRADO
    Printer.FontSize = 8
    Printer.CurrentX = 100: Printer.CurrentY = 1300: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 1300: Printer.Print (": ")
    Printer.CurrentX = 100: Printer.CurrentY = 1500: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 1500: Printer.Print (": ")
    Printer.CurrentX = 100: Printer.CurrentY = 1700: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 1700: Printer.Print (": ")
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = 2023", conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    
    Printer.FontSize = 8
    Printer.CurrentX = 1600: Printer.CurrentY = 1300: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1600: Printer.CurrentY = 1500: Printer.Print (Ngrado & "º " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1600: Printer.CurrentY = 1700: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    ' #################
    
    Printer.FontBold = False
    Printer.Line (50, 2000)-(BordeH, 2350), , B ' ESTE ES EL PRIMER BOX DEL INFORME

    Printer.FontSize = 7
    Printer.CurrentX = 100: Printer.CurrentY = 2100: Printer.Print ("A S I G N A T U R A S")
    Printer.FontSize = 6
    Printer.CurrentX = 4000: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 1º Periodo")
    Printer.CurrentX = 9060: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 2º Periodo")
     
    Aumento = 0
    Printer.FontSize = 6
    Aumento = 0
    For t = 1 To 14
        Aumento = 250 * t
        Printer.CurrentY = 2200
        Printer.CurrentX = 3150 + Aumento
        Printer.Print (t)
        Printer.CurrentY = 2200
        Printer.CurrentX = 8210 + Aumento
        Printer.Print (t)
    Next t
    
    Printer.CurrentX = 7670: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 7670: Printer.CurrentY = 2200: Printer.Print ("1º Periodo")
    Printer.CurrentX = 12730: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 12730: Printer.CurrentY = 2200: Printer.Print ("2º Periodo")
    Printer.CurrentX = 13360: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 13360: Printer.CurrentY = 2200: Printer.Print ("Final")
    
    If Me.chk_lineasverticales.Value = 0 Then
        Printer.Line (3200, 2000)-(3200, 2350) ' linea vertical
        'Printer.Line (7000, 2000)-(7000, 2350) ' linea vertical
        Printer.Line (7630, 2000)-(7630, 2350) ' linea vertical
        Printer.Line (8260, 2000)-(8260, 2350) ' linea vertical
        'Printer.Line (12060, 2000)-(12060, 2350) ' linea vertical
        Printer.Line (12690, 2000)-(12690, 2350) ' linea vertical
        Printer.Line (13320, 2000)-(13320, 2350) ' linea vertical
    End If
    
End Sub


Private Sub ImprimeInformeFinalCab_tall_tri(ByVal rutalumno As String, ByVal Ngrado As String, ByVal letra As String, ByVal NombreModalidad)

    Dim BordeH As Integer

    Call EncabezadoInformeFinal(True)
    If Me.opt_final_parcial(0) Then
        Tipoinforme = UCase(Me.opt_final_parcial(0).Caption)
    ElseIf Me.opt_final_parcial(1) Then
        Tipoinforme = UCase(Me.opt_final_parcial(1).Caption)
    End If
    'BordeH = 13950
    BordeH = 14100
    Printer.FontSize = 8
    Call centrarenpapel(1000, Tipoinforme & " " & Me.lst_periodos.Text & " " & cmb_agno.Text)  ' Este año debe ser el de proceso NO DEL SISTEMA
    ' ACABO DE IMPRIMIR EL TITULO CENTRADO
    Printer.FontSize = 7
    Printer.CurrentX = 100: Printer.CurrentY = 1300: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 1300: Printer.Print (": ")
    Printer.CurrentX = 100: Printer.CurrentY = 1500: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 1500: Printer.Print (": ")
    Printer.CurrentX = 100: Printer.CurrentY = 1700: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 1700: Printer.Print (": ")
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    
    Printer.FontSize = 7
    Printer.CurrentX = 1600: Printer.CurrentY = 1300: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1600: Printer.CurrentY = 1500: Printer.Print (Ngrado & "º " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1600: Printer.CurrentY = 1700: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    ' #################
    
    Printer.FontBold = False
    Printer.Line (50, 2000)-(BordeH, 2350), , B ' ESTE ES EL PRIMER BOX DEL INFORME

    Printer.FontSize = 6
    Printer.CurrentX = 100: Printer.CurrentY = 2100: Printer.Print ("A S I G N A T U R A S")
    Printer.FontSize = 5
    Printer.CurrentX = 3100: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 1º Trimestre")
    Printer.CurrentX = 6870: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 2º Trimestre")
    Printer.CurrentX = 10650: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 3º Trimestre")
     
    Aumento = 0
    Printer.FontSize = 5
    Aumento = 0
    For t = 1 To 14
        Aumento = 215 * t
        Printer.CurrentY = 2200
        Printer.CurrentX = 2100 + Aumento
        Printer.Print (t)
        Printer.CurrentY = 2200
        Printer.CurrentX = 5900 + Aumento
        Printer.Print (t)
        Printer.CurrentY = 2200
        Printer.CurrentX = 9650 + Aumento
        Printer.Print (t)
    Next t
    
'    Printer.CurrentX = 7670: Printer.CurrentY = 2020: Printer.Print ("Promedio")
'    Printer.CurrentX = 7670: Printer.CurrentY = 2200: Printer.Print ("1º Periodo")
'    Printer.CurrentX = 12730: Printer.CurrentY = 2020: Printer.Print ("Promedio")
'    Printer.CurrentX = 12730: Printer.CurrentY = 2200: Printer.Print ("2º Periodo")
'    Printer.CurrentX = 13360: Printer.CurrentY = 2020: Printer.Print ("Promedio")
'    Printer.CurrentX = 13360: Printer.CurrentY = 2200: Printer.Print ("Final")
    
    Printer.CurrentX = 5490: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 5490: Printer.CurrentY = 2200: Printer.Print ("1º Sem.")
    Printer.CurrentX = 9250: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 9250: Printer.CurrentY = 2200: Printer.Print ("2º Sem.")
    Printer.CurrentX = 13010: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 13010: Printer.CurrentY = 2200: Printer.Print ("3º Sem.")
    
    Printer.CurrentX = 13580: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 13580: Printer.CurrentY = 2200: Printer.Print ("Final")


    
    If Me.chk_lineasverticales.Value = 0 Then
'        Printer.Line (3200, 2000)-(3200, 2350) ' linea vertical
'        'Printer.Line (7000, 2000)-(7000, 2350) ' linea vertical
'        Printer.Line (7630, 2000)-(7630, 2350) ' linea vertical
'        Printer.Line (8260, 2000)-(8260, 2350) ' linea vertical
'        'Printer.Line (12060, 2000)-(12060, 2350) ' linea vertical
'        Printer.Line (12690, 2000)-(12690, 2350) ' linea vertical
'        Printer.Line (13320, 2000)-(13320, 2350) ' linea vertical

        Printer.Line (2200, 2000)-(2200, 2350) ' linea vertical
        Printer.Line (5430, 2000)-(5430, 2350) ' linea vertical
        Printer.Line (6000, 2000)-(6000, 2350) ' linea vertical
        Printer.Line (9190, 2000)-(9190, 2350) ' linea vertical
        Printer.Line (9770, 2000)-(9770, 2350) ' linea vertical
        Printer.Line (12960, 2000)-(12960, 2350) ' linea vertical
        Printer.Line (13530, 2000)-(13530, 2350) ' linea vertical
    End If
    
End Sub



Private Sub ImprimeInformeFinalCab_tall_sumativa(ByVal rutalumno As String, ByVal Ngrado As String, ByVal letra As String, ByVal NombreModalidad, tipo_EVA As Integer)

    Dim BordeH As Integer

    Call EncabezadoInformeFinal(True)
    If Me.opt_final_parcial(0) Then
        Tipoinforme = UCase(Me.opt_final_parcial(0).Caption)
    ElseIf Me.opt_final_parcial(1) Then
        Tipoinforme = UCase(Me.opt_final_parcial(1).Caption)
    End If
    BordeH = 13950
    Printer.FontSize = 9
    
    If tipo_EVA = 0 Then
        Tipoinforme = "INFORME FINAL DE NOTAS SUMATIVA"
    Else
        Tipoinforme = "INFORME FINAL DE NOTAS FORMATIVA"
    End If
    'Call centrarenpapel(1000, Tipoinforme & " " & Me.lst_periodos.Text & " " & cmb_agno.Text)  ' Este año debe ser el de proceso NO DEL SISTEMA
    Call centrarenpapel(1000, Tipoinforme & " " & cmb_agno.Text)  ' Este año debe ser el de proceso NO DEL SISTEMA
    ' ACABO DE IMPRIMIR EL TITULO CENTRADO
    Printer.FontSize = 8
    Printer.CurrentX = 100: Printer.CurrentY = 1300: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 1300: Printer.Print (": ")
    Printer.CurrentX = 100: Printer.CurrentY = 1500: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 1500: Printer.Print (": ")
    Printer.CurrentX = 100: Printer.CurrentY = 1700: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 1700: Printer.Print (": ")
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = 2015", conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    
    Printer.FontSize = 8
    Printer.CurrentX = 1600: Printer.CurrentY = 1300: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1600: Printer.CurrentY = 1500: Printer.Print (Ngrado & "º " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1600: Printer.CurrentY = 1700: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    ' #################
    
    Printer.FontBold = False
    Printer.Line (50, 2000)-(BordeH, 2350), , B ' ESTE ES EL PRIMER BOX DEL INFORME

    Printer.FontSize = 7
    Printer.CurrentX = 100: Printer.CurrentY = 2100: Printer.Print ("A S I G N A T U R A S")
    Printer.FontSize = 6
    Printer.CurrentX = 4000: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 1º Periodo")
    Printer.CurrentX = 9060: Printer.CurrentY = 2020: Printer.Print ("Calificaciones Parciales 2º Periodo")
     
    Aumento = 0
    Printer.FontSize = 6
    Aumento = 0
    For t = 1 To 14
        Aumento = 250 * t
        Printer.CurrentY = 2200
        Printer.CurrentX = 3150 + Aumento
        Printer.Print (t)
        Printer.CurrentY = 2200
        Printer.CurrentX = 8210 + Aumento
        Printer.Print (t)
    Next t
    
    Printer.CurrentX = 7670: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 7670: Printer.CurrentY = 2200: Printer.Print ("1º Periodo")
    Printer.CurrentX = 12730: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 12730: Printer.CurrentY = 2200: Printer.Print ("2º Periodo")
    Printer.CurrentX = 13360: Printer.CurrentY = 2020: Printer.Print ("Promedio")
    Printer.CurrentX = 13360: Printer.CurrentY = 2200: Printer.Print ("Final")
    
    If Me.chk_lineasverticales.Value = 0 Then
        Printer.Line (3200, 2000)-(3200, 2350) ' linea vertical
        'Printer.Line (7000, 2000)-(7000, 2350) ' linea vertical
        Printer.Line (7630, 2000)-(7630, 2350) ' linea vertical
        Printer.Line (8260, 2000)-(8260, 2350) ' linea vertical
        'Printer.Line (12060, 2000)-(12060, 2350) ' linea vertical
        Printer.Line (12690, 2000)-(12690, 2350) ' linea vertical
        Printer.Line (13320, 2000)-(13320, 2350) ' linea vertical
    End If
    
End Sub


Sub Imprimeencabezadopant_sanbe(tipo_EVA As Integer)
Dim colegio As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
Dim var_sql As String
var_sql = "select valor from cfg where param = 'codbc'"
objRS.Open var_sql, conn
colegio = objRS("valor")
objRS.Close

var_sql = "select month(now()) as mes"
objRS.Open var_sql, conn
mes = objRS("mes")
objRS.Close

Call encabezadopapel(True)
'If Me.opt_final_parcial(0) Then
'    Tipoinforme = "INFORME FINAL DE NOTAS"
'ElseIf Me.opt_final_parcial(1) Then
'    Tipoinforme = "INFORME PARCIAL DE NOTAS"
'End If

numperiodo = aperiodos(Me.lst_periodos.ListIndex)

If numperiodo = 0 Then
If mes > 6 Then
    Tipoinforme = "INFORME FINAL DE NOTAS"
Else
    Tipoinforme = "INFORME PARCIAL DE NOTAS"
End If
End If

'If numperiodo = 1 Then
'If Mes > 11 Then
'    Tipoinforme = "INFORME FINAL DE NOTAS"
'Else
If tipo_EVA = 0 Then
    Tipoinforme = "INFORME DE NOTAS SUMATIVA"
Else
    Tipoinforme = "INFORME DE NOTAS FORMATIVA"
End If
'End If
'End If

Printer.FontSize = 9
Call centrarenpapel(1000, Tipoinforme & " " & lst_periodos.Text & " " & cmb_agno.Text)    ' Este año debe ser el de proceso NO DEL SISTEMA
Printer.FontSize = 8

'''''If colegio <> "LIN001" Then
'''''    Printer.PaintPicture LoadPicture("\\192.168.7.14\logo\logo.gif"), 10000, 880
'''''Else
'''''    Printer.PaintPicture LoadPicture("c:\Archivos de programa\Ges_Col\objetos\insignia_lincoln.gif"), 10000, 880
'''''End If

Printer.CurrentX = 100: Printer.CurrentY = 1400: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 1400: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 1600: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 1600: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 1800: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 1800: Printer.Print (":")
Printer.FontBold = False
Printer.Line (50, 2500)-(11500, 3000), , B  ' ESTE ES EL PRIMER BOX DEL INFORME
Printer.FontBold = True
Printer.FontSize = 10
Printer.CurrentX = 100: Printer.CurrentY = 2650: Printer.Print ("A S I G N A T U R A S")
Printer.FontBold = False
Printer.FontSize = 8
Aumento = 0
Printer.FontSize = 8
For t = 1 To 12
    Aumento = Aumento + 350 + 52
    Printer.CurrentX = 3400
    Printer.CurrentX = Printer.CurrentX + Aumento
    Printer.CurrentY = 2750
    Printer.Print (t)
Next t

Printer.FontSize = 7

Printer.CurrentX = 8600: Printer.CurrentY = 2550: Printer.Print ("PROM.")
Printer.CurrentX = 8600: Printer.CurrentY = 2700: Printer.Print ("PARC.")

Printer.CurrentX = 9200: Printer.CurrentY = 2550: Printer.Print ("NOTA")
Printer.CurrentX = 9200: Printer.CurrentY = 2700: Printer.Print ("EXAM.")

Printer.CurrentX = 9780: Printer.CurrentY = 2550: Printer.Print ("PROM.")
Printer.CurrentX = 9780: Printer.CurrentY = 2700: Printer.Print (" 80%")

Printer.CurrentX = 10370: Printer.CurrentY = 2550: Printer.Print ("EXAM.")
Printer.CurrentX = 10370: Printer.CurrentY = 2700: Printer.Print (" 20%")

Printer.CurrentX = 10980: Printer.CurrentY = 2550: Printer.Print ("PROM.")
Printer.CurrentX = 10980: Printer.CurrentY = 2700: Printer.Print (" SEM.")

Printer.FontSize = 8

Printer.Line (3650, 2500)-(3650, 3100), , B         ' linea vertical
'Printer.Line (10600, 2500)-(10600, 3100), , B    ' linea vertical
End Sub

Function Imprimenotasalumnopant_sanbe(rutalumno As String, Ngrado As String, letra As String, CodModalidad As String, NombreModalidad As String, numperiodo As String, tipo_EVA As Integer) As Long
 '   On Error Resume Next
    Dim Promsemestre As String
    Dim procur As String
    Dim y1, y2, y3, cont, prom As Double
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    Dim rsnotas As ADODB.Recordset
    Set rsnotas = New ADODB.Recordset
    Dim especial_prom As Double
    Dim especial_cont As Integer
    
    cn_posx = 0
    '
    Dim Promproceso As Single, Promponderado As Single, valnota As Single   'notasincoma As Single, nota As Single,
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    Printer.FontSize = 8
    Printer.CurrentX = 1600: Printer.CurrentY = 1400: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1600: Printer.CurrentY = 1600: Printer.Print (Ngrado & " " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1600: Printer.CurrentY = 1800: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    Dim RsAux As ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    RsAux.CursorLocation = adUseClient
'    var_sql = "select *" _
'            & " from subsectores s,asi_x_cur_prof ap" _
'            & " where s.num_gra = ap.num_gra and s.cod_asi = ap.cod_asi and s.cod_ens = ap.cod_ens and" _
'            & " ap.cod_ens = '" & CodModalidad & "' and ap.num_gra = '" & Ngrado & "' and ord_asi <> 0 and ap.let_cur = '" & Letra & "'" _
'            & " and agno = " & Cmb_Agno.Text & " order by ord_asi"
'Volver atras
    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
        'var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and ci_alu = '" & rutalumno & "' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
        'se modifica consulta 22-06-2022
        var_sql = ""
        var_sql = " SELECT * FROM subsectores S"
        var_sql = var_sql & " JOIN notas  N"
        var_sql = var_sql & " ON  s.cod_ens = n.cod_ens"
        var_sql = var_sql & " AND s.num_gra = n.num_gra"
        var_sql = var_sql & " AND s.cod_asi = n.cod_asi"
        var_sql = var_sql & " AND s.cod_sec = n.cod_sec"
        var_sql = var_sql & " WHERE n.ci_alu = '" & rutalumno & "'"
        var_sql = var_sql & " AND TRIM(n.nota) <> ''"
        var_sql = var_sql & " AND n.agno = '" & Anno & "'"
        var_sql = var_sql & " AND n.cod_ens = '" & CodModalidad & "'"
        var_sql = var_sql & " AND n.num_gra = '" & Ngrado & "'"
        var_sql = var_sql & " AND n.letra_curso = '" & letra & "'"
        var_sql = var_sql & " AND n.num_per = '0'"
        var_sql = var_sql & " AND n.tipo_eva = 0"
        var_sql = var_sql & " AND S.ord_asi <> 0"
        var_sql = var_sql & " ORDER BY S.ord_asi"

        
    Else
    'var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & Letra & "' AND num_per = '0' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
        If ((val(Ngrado) = 1 Or val(Ngrado) = 2) And CodModalidad = "310") Then
            var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 AND not (cod_asi = 3 OR cod_asi = 8 OR cod_asi = 7) ORDER BY ord_asi"
        Else
            var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 ORDER BY ord_asi"
        End If
    End If
'''    'Ahora se muestran todos las asignaturas aunque no estan ingresadas notas
'''    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
'''    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi ORDER BY ord_asi"
'''    Else
'''    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi ORDER BY ord_asi"
'''    End If
    
    
    RsAux.Open var_sql, conn
    'Aqui acabo de seleccionar los sectores y asignaturas
    'correspondientes al nivel del alumno.
    promfinal = 0: Sumapromedios = 0
    If RsAux.RecordCount > 0 Then 'Si se encontraron asignaturas en el curso
        'Dim rsnotas As ADODB.Recordset
        Set rsnotas = New ADODB.Recordset
        'rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        y1 = 2500
        prom = 0
        cont = 0
            ydeproceso = 2680
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B 'ESTE ES EL PRIMER BOX DEL INFORME
                
                Sector = RsAux("cod_sec")
                Codasi = RsAux("cod_asi")
                Nombreasig = RsAux("nom_asi")
                
                ''''''pregunta para dejar el recuadro de las notas con sangria
'''''''''                If (val(Ngrado) = 1 And CodModalidad = "310") And (val(Sector) = 11 And (val(Codasi) = 3 Or val(Codasi) = 8 Or val(Codasi) = 7)) Then
'''''''''                    Printer.Line (500, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
'''''''''                    especial = 1
'''''''''                Else
                    Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                    especial = 0
'''''''''                End If
                If ((val(Ngrado) = 1 Or val(Ngrado) = 2) And CodModalidad = "310") Then
                    rsnotas.Open "select cod_sec, cod_asi, num_per, cod_eva, nota from notas where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and num_per = '" & numperiodo & "' and agno = " & cmb_agno.Text & " AND not (cod_asi = 3 OR cod_asi = 8 OR cod_asi = 7) and tipo_eva = " & tipo_EVA & " order by cod_sec, cod_asi", conn
                Else
                     rsnotas.Open "select cod_sec, cod_asi, num_per, cod_eva, nota from notas where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and num_per = '" & numperiodo & "' and agno = " & cmb_agno.Text & " and tipo_eva = " & tipo_EVA & " order by cod_sec, cod_asi", conn
                End If
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = 2580 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                'Printer.CurrentX = 100
                
                '''''' Campo especial
''''''''                If especial = 1 Then
''''''''                    Printer.CurrentX = 500
''''''''                Else
                    Printer.CurrentX = 100
''''''''                End If
                
                Printer.FontSize = 8
                Printer.Print (Nombreasig) ' Imprimo asignatura
                
                Printer.CurrentY = 2780 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 1000
                Printer.FontSize = 6
                'Printer.Print "APRENDIZAJE        100%" 'Imprimo asignatura
                
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                    '''' modifico if
                    If val(rsnotas("nota")) <> 0 Or (val(Sector) = 11 And val(Codasi) = 6) Then
                    notas = rsnotas("nota")
                    
                    '''''' Posicion naturales
'                    If (val(Sector) = 11 And val(Codasi) = 6) Then
''                       posy = 5700
'                       posx = 10700 + 300
'                       posy = Printer.CurrentY
'                    End If
                    For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        If tnotas < 25 Then
                            aumentonota = aumentonota + 408
                        End If
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        If tnotas < 25 Then
                            Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                            Printer.CurrentY = ydeproceso + 100
                        End If
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 And notasincoma <> " P" Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
'                                   ''''' Promedio especial
'                                   If especial = 1 Then
'                                            especial_prom = especial_prom + Nota
'                                            especial_cont = especial_cont + 1
'                                            'especial_promc = especial_promc + pro
'                                    Else
'                                            'Printer.Print (Nota)
'                                    End If
                            
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0"))
                        End If 'sin necesidad de agregarle coma como texto.
                        If tnotas < 25 Then
                            Divisor = Divisor + 1
                        End If
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        
                        'Para que no se impriman notas parciales y examen
                        If tnotas < 25 Then
                            If rsnotas("cod_asi") = 13 Then
                                eximi = ""
                                eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = 13 and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                                If Len(eximi) > 5 Then
                                    'Printer.Print ("Ex.")
                                Else
                                    Printer.Print (Nota)
                                End If
                            Else
'''''''''                                If rsnotas("cod_asi") <> 6 Then Printer.Print (Nota)
                                Printer.Print (Nota)
                                             ''''' Promedio especial
'''''''''                                   If especial = 1 Then
'''''''''                                            If Nota <> " " Then
'''''''''                                                especial_prom = especial_prom + Nota
'''''''''                                                especial_cont = especial_cont + 1
'''''''''                                            End If
'''''''''                                            'especial_promc = especial_promc + pro
'''''''''                                    Else
'''''''''                                            'Printer.Print (Nota)
'''''''''                                    End If
                            End If
                        ElseIf tnotas = 25 Then
                            Printer.FontBold = False
                            Printer.CurrentX = Printer.CurrentX + aumentonota + 1200 - 50
                            Printer.CurrentY = ydeproceso + 100
                               '''''' naturales
'''''''''                            If (val(Ngrado) = 1 And CodModalidad = "310") And (val(Codasi) = 6) Then
'''''''''                                cn_posx = Printer.CurrentX + aumentonota + 600 - 50
'''''''''                                cn_poxy = Printer.CurrentY
'''''''''                                Printer.Print (Nota)
'''''''''                            Else
                                Printer.Print (Nota)
'''''''''                            End If
                            
                            Printer.CurrentX = 3300
                            'Printer.CurrentX = Printer.CurrentX + aumentonota + 1200 - 150 + 600
                            
                            Printer.CurrentX = Printer.CurrentX + aumentonota + 1200 - 200 + 1200 + 50
                            Printer.CurrentY = ydeproceso + 100
                            If Nota <> " " Then
                                'Printer.Print Format((Nota * 0.2), "0.00")
                                '''''''' Naturales
'''''''''                                If (val(Ngrado) = 1 And CodModalidad = "310") And (val(Codasi) = 6) Then
'''''''''                                    cn_posx80 = Printer.CurrentX + aumentonota + 1200 - 150 + 600 + 50
'''''''''                                    c_n_examen = Format(Int(Round((Nota * 0.2) * 10, 1)) / 10, "0.0")
'''''''''                                    Printer.Print Format(Int(Round((Nota * 0.2) * 10, 1)) / 10, "0.0")
'''''''''                                Else
                                    Printer.Print Format((((Nota * 0.2) * 10)) / 10, "0.00")
'''''''''                                End If
                                'Printer.Print Format(Int(Round((Nota * 0.2) * 10, 1)) / 10, "0.0")
                                'c_n_examen = Format(Int(Round((Nota * 0.2) * 10, 1)) / 10, "0.0")
                            End If
                        ElseIf tnotas = 27 Then
                          If CStr(Mid(notas, 25, 2)) <> "  " Then
                            Printer.FontBold = False
                            Printer.CurrentX = Printer.CurrentX + aumentonota + 600 - 50
                            Printer.CurrentY = ydeproceso + 100
                            '''''' naturales
'''''''''                            If (val(Ngrado) = 1 And CodModalidad = "310") And (val(Codasi) = 6) Then
'''''''''                                cn_posx = Printer.CurrentX
'''''''''                                cn_poxy = Printer.CurrentY
'''''''''                            Else
                                Printer.Print (Nota)
'''''''''                            End If
                            Printer.CurrentX = 3300
                            'Printer.CurrentX = Printer.CurrentX + aumentonota + 1200 - 200 + 1200
                            Printer.CurrentX = Printer.CurrentX + aumentonota + 1200 - 150 + 600 + 50
                            Printer.CurrentY = ydeproceso + 100
                            If Nota <> " " Then
                                'Printer.Print Format((Nota * 0.8), "0.00")
                                '''''''' Naturales
''''''''''                                If (val(Ngrado) = 1 And CodModalidad = "310") And (val(Codasi) = 6) Then
''''''''''                                    cn_posx80 = Printer.CurrentX
''''''''''                                Else
''''''''''
                                    Printer.Print Format((((Nota * 0.8) * 10)) / 10, "0.00")
''''''''''                                End If
                            End If
                          End If
                        Else
                        End If
                                                
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                
                rsnotas.Open "select * from promedios where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and agno = " & cmb_agno.Text & " and tipo_eva = " & tipo_EVA & " order by cod_sec, cod_asi", conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If numperiodo = 0 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    If Nota < 4# Then
                        Printer.FontBold = False
                    Else
                        Printer.FontBold = False
                    End If
                    Promsemestre = ""
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    
                    If Not (rsnotas("cod_asi") = 13 Or rsnotas("cod_asi") = 22) Then
                        var_sql = "select if(count(*)>0,'SI','NO') as ex from promedios p,acta_alumexi a" _
                                & " where p.ci_alu = a.run_alu and p.cod_asi = a.cod_asi and p.ci_alu = '" & rutalumno & "'" _
                                & " and p.cod_asi = '" & rsnotas("cod_asi") & "' and a.agno = " & cmb_agno.Text _
                                & " and p.agno = a.agno and tipo_eva = " & tipo_EVA
                        objRS.Open var_sql, conn
                        exi = objRS("ex")
                        objRS.Close
                        If exi = "NO" Then
                            If val(Replace(Nota, ",", ".")) <> "0,0" Then
                                     ''''' No sumar biologia quimica fisica
''''''''                                If Not ((rsnotas("cod_asi") = 6 Or rsnotas("cod_asi") = 3 Or rsnotas("cod_asi") = 8 Or rsnotas("cod_asi") = 7) And CodModalidad = "310" And Ngrado = 1) Then
                                If Not ((rsnotas("cod_asi") = 3 Or rsnotas("cod_asi") = 8 Or rsnotas("cod_asi") = 7) And CodModalidad = "310" And (Ngrado = 1 Or Ngrado = 2)) Then
                                cont = cont + 1
                                prom = prom + val(Replace(Nota, ",", "."))
''''''''                                If rsnotas("cod_asi") <> 6 Then Printer.Print (Nota)
                                Printer.Print (Nota)
                                End If
                                
''''                                cont = cont + 1
''''                                prom = prom + val(Replace(Nota, ",", "."))
''''                                If Me.opt_final_parcial(0) Then
''''                                    Printer.Print ("  " & Nota)
''''                                End If
                            End If
                        Else
                            Printer.Print (" Ex.")
                        End If
                        
                        
                    Else
                        If Me.opt_final_parcial(0) Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = " & rsnotas("cod_asi") & " and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                Printer.Print (" Ex.")
                            Else
                                If (rsnotas("cod_asi") = "13" And Promsemestre = "EX") Or Nota = "0,0" Then
                                Else
                                Printer.Print ("  " & Promsemestre)
                                End If
                            End If
                        End If
                    End If
                    Printer.FontBold = False
                    
                End If
                
                        ''''imprime naturales
''''''''''''''                        If posy <> 0 Then
''''''''''''''                            Printer.CurrentY = posy
''''''''''''''                            Printer.CurrentX = posx - 50
''''''''''''''                        If (CodModalidad = "310" Or Ngrado = 1) And val(Codasi) = 6 And especial_prom <> 0 Then
''''''''''''''                            If cn_posx <> 0 And c_n_examen <> 0 Then
''''''''''''''                            If Len(Mid(especial_prom / especial_cont, 1, 3)) <> 1 Then
''''''''''''''                                'Printer.Print (Mid(especial_prom / 3, 1, 3)) & "    " & (Mid(especial_promc / 3, 1, 3))
''''''''''''''                                Printer.CurrentX = 8746 'cn_posx
''''''''''''''                                c_n = (Mid(Trim(CStr(especial_prom / especial_cont)), 1, 3))
''''''''''''''                                sw = 1
''''''''''''''                                Printer.FontSize = 9
''''''''''''''                                Printer.Print (c_n)
''''''''''''''                                Printer.CurrentX = 9896 'cn_posx80
''''''''''''''                                Printer.CurrentY = posy
''''''''''''''                                Printer.Print Format(Int(Round((c_n * 0.8) * 10, 1)) / 10, "0.0")
''''''''''''''                                'examen + promedio
''''''''''''''                                Printer.CurrentY = posy
''''''''''''''                                Printer.CurrentX = posx - 50
''''''''''''''                                Printer.Print Format(CDbl(Format(Int(Round((c_n * 0.8) * 10, 1)) / 10, "0.0")) + CDbl(c_n_examen), "0.0")
''''''''''''''                                c_n_x = Format(CDbl(Format(Int(Round((c_n * 0.8) * 10, 1)) / 10, "0.0")) + CDbl(c_n_examen), "0.0")
''''''''''''''                            Else
''''''''''''''                                'Printer.Print (Mid(especial_prom / 3, 1, 3)) & ",0    " & (Mid(especial_promc / 3, 1, 3))
''''''''''''''                                Printer.CurrentX = cn_posx
''''''''''''''                                c_n = (Mid(Format(Trim(CStr(especial_prom / especial_cont)), "0.0"), 1, 3))
''''''''''''''                                sw = 1
''''''''''''''                                Printer.FontSize = 9
''''''''''''''                                Printer.Print (c_n)
''''''''''''''                                Printer.CurrentX = cn_posx80
''''''''''''''                                Printer.CurrentY = posy
''''''''''''''                                Printer.Print Format(Int(Round((c_n * 0.8) * 10, 1)) / 10, "0.0")
''''''''''''''                                 'examen + promedio
''''''''''''''                                Printer.CurrentY = posy
''''''''''''''                                Printer.CurrentX = posx - 50
''''''''''''''                                Printer.Print Format(CDbl(Format(Int(Round((c_n * 0.8) * 10, 1)) / 10, "0.0")) + CDbl(c_n_examen), "0.0")
''''''''''''''                                c_n_x = Format(CDbl(Format(Int(Round((c_n * 0.8) * 10, 1)) / 10, "0.0")) + CDbl(c_n_examen), "0.0")
''''''''''''''                            End If
''''''''''''''                            Else
''''''''''''''                            If Len(Mid(especial_prom / especial_cont, 1, 3)) <> 1 Then
''''''''''''''                                'Printer.Print (Mid(especial_prom / 3, 1, 3)) & "    " & (Mid(especial_promc / 3, 1, 3))
''''''''''''''                                c_n = (Mid(Trim(CStr(especial_prom / especial_cont)), 1, 3))
''''''''''''''                                sw = 1
''''''''''''''                                Printer.FontSize = 9
''''''''''''''                                Printer.Print (c_n)
''''''''''''''                                c_n_x = c_n
''''''''''''''                            Else
''''''''''''''                                'Printer.Print (Mid(especial_prom / 3, 1, 3)) & ",0    " & (Mid(especial_promc / 3, 1, 3))
''''''''''''''                                c_n = (Mid(Format(Trim(CStr(especial_prom / especial_cont)), "0.0"), 1, 3))
''''''''''''''                                sw = 1
''''''''''''''                                Printer.FontSize = 9
''''''''''''''                                Printer.Print (c_n)
''''''''''''''                                c_n_x = c_n
''''''''''''''                            End If
''''''''''''''                            End If
''''''''''''''                        End If
''''''''''''''                        End If

                rsnotas.Close
                RsAux.MoveNext
            Wend
                        
            Printer.Line (3650, 2700)-(3650, y1 + 500)   'linea vertical
            'Printer.Line (10600, 2700)-(10600, y1 + 500) 'linea vertical
            For y2 = 1 To 12
                If y2 <= 12 Then
                    Printer.Line (3650 + (408 * y2), 2500)-(3650 + (408 * y2), y1 + 500) 'linea vertical
                End If
            Next y2
            Printer.Line (3830 + (408 * 13), 2500)-(3830 + (408 * 13), y1 + 500)
            Printer.Line (4010 + (408 * 14), 2500)-(4010 + (408 * 14), y1 + 500)
            Printer.Line (4190 + (408 * 15), 2500)-(4190 + (408 * 15), y1 + 500)
            Printer.Line (4370 + (408 * 16), 2500)-(4370 + (408 * 16), y1 + 500)
            
            'Printer.Line (3250 + (408 * y2), y1 + 600)-(3250 + (408 * y2), y1 + 1000) 'linea vertical
            'Printer.Line (10600, y1 + 600)-(10600, y1 + 1000) 'linea vertical
            
            y1 = y1 + 500
            Printer.Line (50, CLng(y1 + 100))-(11500, CLng(y1 + 500)), , B
            Printer.CurrentY = y1 + 250
            
            Printer.FontSize = 8
            Printer.CurrentX = 100
            'Printer.CurrentY = y1 + 250
            'Asistencia
            'rutalumno nombre de campo
            
            var_sql = "SELECT ci_alu,a.mes_asis,asi_r,asi_t,(100 * SUM(asi_t))/SUM(asi_r) AS porcentaje FROM asistencia a,fnza_conversion_meses c" _
                    & " WHERE a.mes_asis = c.abv_mes AND c.num_mes <= DATE_FORMAT(NOW(),'%m') AND agno = " & cmb_agno.Text & " AND ci_alu = '" & rutalumno & "'" _
                    & " GROUP BY ci_alu"
            objRS.Open var_sql, conn
            If objRS.RecordCount > 0 Then
                If objRS("porcentaje") = 100 Then
                    Printer.Print "Porcentaje de Asistencia: " & Format(objRS("porcentaje"), "0.0") & "%                                                                                                                            PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
                Else
                    Printer.Print "Porcentaje de Asistencia: " & Format(objRS("porcentaje"), "0.0") & "%                                                                                                                              PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
                End If
            Else
                Printer.Print "Porcentaje de Asistencia:                                                                                                                                      PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
            End If
            objRS.Close
                      
            
            Printer.CurrentX = 8000
            Printer.FontSize = 8
            'Printer.Print "PROMEDIO FINAL DEL PERIODO" 'Imprimo asignatura
            Printer.CurrentY = y1 + 250
            Printer.CurrentX = 10950
            Dim NotaFinalInf As String
            
            '''' promedio naturales
            If prom <> 0 And cont <> 0 Then
                '''' Promedio si es ciencias naturales
'''''''                If val(Ngrado) = 1 And CodModalidad = "310" And c_n <> 0 Then
'''''''                    NotaFinalInf = Trim(str((prom + c_n_x) / (cont + 1)))
'''''''                Else
                    NotaFinalInf = Trim(str(prom / cont))
'''''''                End If
            Else
                NotaFinalInf = 0
            End If
            
            cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
            If cole = "LIN001" Then
                If prom <> 0 And cont <> 0 Then
                    NotaFinalInf = (prom / cont) + 0.05
            Else
                    NotaFinalInf = 0
            End If
            End If
            
            NotaFinalInf = Mid(NotaFinalInf, 1, 1) & "," & val(Mid(NotaFinalInf, 3, 1))
            If val(NotaFinalInf) < 4 Then
                Printer.FontBold = True
            Else
                Printer.FontBold = False
            End If
            If Me.opt_final_parcial(0) Then
                If NotaFinalInf <> "0,0" Then
                    'Printer.Print (NotaFinalInf)
                     If NotaFinalInf <> ",0" Then
                        Printer.Print ("  " & NotaFinalInf)
                     End If
                End If
            End If
            Printer.FontBold = False
    End If
    RsAux.Close
    
    
'TALLERES CURRICULARES
    var_sql = "select * from talleres where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and tipo_tall = 1"
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
    
        y1 = y1 + 500
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 200
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print ("T A L L E R E S    C U R R I C U L A R E S")
        Printer.FontBold = False

        'rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
            ydeproceso = ydeproceso + 500
            y3 = y1 + 500
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
   
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = Y4 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
         
                    For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0"))
                        End If 'sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        If Nota <> "0.0" Then
                            Printer.Print (Nota) 'La notas sale sin problemas
                        End If
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                                      
                rsnotas.Open var_sql, conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950 '11100
                    If (numperiodo + 1) = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 2, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 2, 1))
                    End If
                    

                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    
                    
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                    
'                    If colegio = "FAR001" Then
'                        Printer.Print (Nota)
'                    Else
                        ' Printer.Print (Promsemestre) esto es para imprimir por concepto
                        Printer.Print (Nota)
'                    End If
                    
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If
                '
                rsnotas.Close
                RsAux.MoveNext
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 500)   'linea vertical
            Printer.Line (10900, CInt(y3))-(10900, y1 + 500) 'linea vertical
            'Printer.Line (4370 + (408 * 16), 2500)-(4370 + (408 * 16), y1 + 500)
            For y2 = 1 To 12
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 500) 'linea vertical
            Next y2
    End If
    RsAux.Close
    
    var_sql = "select * from talleres t,alumnos_talleres at" _
            & " where at.ci_alu = '" & rutalumno & "' and t.cod_ens = at.cod_ens" _
            & " and t.cod_tall = at.cod_tall" _
            & " and t.num_gra = at.numgra and t.tipo_tall = at.tipo_tall" _
            & " and at.let_cur = '" & letra & "' and at.cod_ens = '" & CodModalidad & "'" _
            & " and at.numgra = '" & Ngrado & "' and t.tipo_tall = 2 and agno = " & cmb_agno.Text
            
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
        y1 = y1 + 500
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 200
    
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print "T A L L E R E S    L I B R E    ELECCIÓN"
        Printer.FontBold = False

       ' rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
            ydeproceso = ydeproceso + 500
            y3 = y1 + 500
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
                      
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = Y4 'Donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
                    
            For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0")) 'Round(CDec(Val(Nota * 1.01)), 1) ' aqui debo dejar un numero entero 4 como 4,0
                        End If ' sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        Printer.Print (Nota)
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                              
                rsnotas.Open var_sql, conn
            If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950 '11100
                    If numperiodo + 1 = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                    
'                    If colegio = "FAR001" Then
'                        Printer.Print (Nota)
'                    Else
                        'Printer.Print (Promsemestre) imprimir por concepto
                        Printer.Print (Nota)
                   ' End If
                    
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If
                rsnotas.Close
                RsAux.MoveNext
               
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 500) 'linea vertical
            For y2 = 1 To 12
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 500) 'linea vertical
            Next y2
            Printer.Line (10900, CInt(y3))-(10900, y1 + 500)
            'Printer.Line (4370 + (408 * 16), 2500)-(4370 + (408 * 16), y1 + 500)
    End If
    RsAux.Close
    Imprimenotasalumnopant_sanbe = y1
End Function

Sub imprimepiepant_tall(posicion As Integer, CodModalidad As String, Ngrado As String, letra As String)
Dim I As Single, linea1 As Single, linea2 As Single
I = posicion + 400
Printer.FontSize = 8
Printer.CurrentX = 200: Printer.CurrentY = I + 650: Printer.Print ("OBSERVACIONES")
Printer.Line (200 + Printer.TextWidth("OBSERVACIONES") + 100, I + 800)-(11500, I + 800)
Printer.Line (200, I + 1100)-(11500, I + 1100)
RutProfe = DevuelveCampo("cursos", "", "rut_prof", "agno=" & cmb_agno.Text & " and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'", conn)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select noms_prof, ape1_prof, ape2_prof, hor_ate_prof from profesores where rut_prof = '" & RutProfe & "'", conn
If rs.RecordCount Then
    nombreprofe = rs("noms_prof")
    ape1profe = rs("ape1_prof")
    ape2profe = rs("ape2_prof")
    horario = rs("hor_ate_prof")
End If
rs.Close
rs.Open "select RDB,nom_dir, ape_pat_dir, ape_mat_dir,nom_dir_sub, ape_pat_dir_sub, ape_mat_dir_sub from establecimientos", conn
If rs.RecordCount Then
    RDB = rs("rdb")
    If RDB = "26260-9" Then
        Nombredir = rs("nom_dir_SUB")
        ape1dir = rs("ape_pat_dir_sub")
        ape2dir = rs("ape_mat_dir_sub")
    Else
        Nombredir = rs("nom_dir")
        ape1dir = rs("ape_pat_dir")
        ape2dir = rs("ape_mat_dir")
    End If
End If
rs.Close

Nombreprofejefe = nombreprofe & " " & ape1profe & " " & ape2profe
Cargo1 = "PROFESOR(A) JEFE"
Nombredirec = Nombredir & " " & ape1dir & " " & ape2dir
'If RDB = "26260-9" Then
'    Cargo2 = "DIRECTORA SUBROGANTE"
'Else
    Cargo2 = "DIRECTOR(A)"
'End If
    mitad = (Printer.ScaleWidth / 2) / 2
    largotexto = Printer.TextWidth(Nombreprofejefe)
    linea1 = mitad - (largotexto / 2) '+ (Printer.ScaleWidth / 2)
    Printer.Line (linea1, I + 1800)-(linea1 + Printer.TextWidth(Nombreprofejefe), I + 1800)      ' linea de firma del profesor jefe
    Printer.CurrentX = linea1: Printer.CurrentY = I + 1850: Printer.Print (Nombreprofejefe)
    largotexto = Printer.TextWidth(Cargo1) ' calculo la posicion del cargo del profe
    linea1 = mitad - (largotexto / 2) '+ (Printer.ScaleWidth / 2)
    Printer.CurrentX = linea1: Printer.CurrentY = I + 2000: Printer.Print (Cargo1)
'***************************************************************************************
    mitad = (Printer.ScaleWidth / 2) / 2
    largotexto = Printer.TextWidth(Nombredirec)
    linea2 = mitad - (largotexto / 2) + (Printer.ScaleWidth / 2)
    Printer.Line (linea2, I + 1800)-(linea2 + Printer.TextWidth(Nombredirec), I + 1800)      ' linea de firma de la directora
    Printer.CurrentX = linea2: Printer.CurrentY = I + 1850: Printer.Print (Nombredirec)
    largotexto = Printer.TextWidth(Cargo2)
    linea2 = mitad - (largotexto / 2) + (Printer.ScaleWidth / 2)
    Printer.CurrentX = linea2: Printer.CurrentY = I + 2000: Printer.Print (Cargo2)
End Sub

Private Sub agrega_log()

    Dim fs As Object
    Set fs = CreateObject("Scripting.FileSystemObject")
    Dim strrutaorigen$, strrutadestino$
    'strrutaorigen$ = "C:\cabs\Ges_Col.exe"
    strrutaorigen$ = "\\192.168.7.91\logos\aguilita.gif"
    strrutadestino$ = App.Path & "\aguilita.gif"
    FileCopy strrutaorigen$, strrutadestino$
    Set fs = Nothing
End Sub

Function Imprimenotasalumnopant_alt(rutalumno As String, Ngrado As String, letra As String, CodModalidad As String, NombreModalidad As String, numperiodo As String) As Long
    Dim Promsemestre As String
    Dim notass As String
    Dim notass2 As String
    Dim a As Integer, b As Integer, c As Integer
    Dim m1 As String, m2 As String, m3 As String
    'Dim mayor1 As String, mayor2 As String, mayor3 As String
    Dim p1 As Integer, p2 As Integer, p3 As Integer, sw As Integer
        
    Dim y1, y2, y3, cont, prom As Double
    '
    Dim Promproceso As Single, Promponderado As Single, valnota As Single   'notasincoma As Single, nota As Single,
    ci_alu = DevuelveCampo("postulantes", "", "ci_alu", "ci_alu ='" & rutalumno & "'", conn)
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    Printer.FontSize = 8
    Printer.CurrentX = 1500: Printer.CurrentY = 2600: Printer.Print (ci_alu)
    Printer.CurrentX = 1500: Printer.CurrentY = 2900: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1500: Printer.CurrentY = 3200: Printer.Print (Ngrado & " " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1500: Printer.CurrentY = 3500: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    Dim RsAux As ADODB.Recordset
    
    Dim pro As String 'promedio curso asignatura
    Dim especial As Integer
    Dim especial_prom As Double
    Dim especial_promc As Double
    Dim posy As Integer
    Dim posx As Integer
    Dim inglesvar As Integer
    Dim inglesprom As Double
    
    Dim mayor1 As Double
    Dim mayor2 As Double
    Dim mayor3 As Double
    
    Dim posy2 As Integer
    Dim posx2 As Integer
    
    Dim promleng As Double
    Dim tnotasl As Integer
    
    sw = 0
    posy = 0
    posx = 0
    inglesvar = 0
    inglesprom = 0
    tnotasl = 1
    
    posy2 = 0
    posx2 = 0
    
    Set RsAux = New ADODB.Recordset
    RsAux.CursorLocation = adUseClient
'    var_sql = "select *" _
'            & " from subsectores s,asi_x_cur_prof ap" _
'            & " where s.num_gra = ap.num_gra and s.cod_asi = ap.cod_asi and s.cod_ens = ap.cod_ens and" _
'            & " ap.cod_ens = '" & CodModalidad & "' and ap.num_gra = '" & Ngrado & "' and ord_asi <> 0 and ap.let_cur = '" & Letra & "'" _
'            & " and agno = " & Cmb_Agno.Text & " order by ord_asi"
    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and ci_alu = '" & rutalumno & "' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
    Else
    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
    End If
    RsAux.Open var_sql, conn
    'Aqui acabo de seleccionar los sectores y asignaturas correspondientes al nivel del alumno.
    promfinal = 0: Sumapromedios = 0
    
    If RsAux.RecordCount > 0 Then 'Si se encontraron asignaturas en el curso
        Dim rsnotas As ADODB.Recordset
        Set rsnotas = New ADODB.Recordset

        Aumentosector = 0 '****Separacion vertical nombre subsectores****
        Totalsubsectores = 0
        y1 = 4000 '**Posicion recuadro notas**
        prom = 0
        cont = 0
        ydeproceso = 3920 '**Posicion inicial impresion de notas**
        Printer.Line (50, CLng(3900))-(11500, CLng(3900 + 500)), , B '**Tercer recuadro informe subsectores**
        
        
                
            While Not RsAux.EOF
                y1 = y1 + 400
                
                Sector = RsAux("cod_sec")
                Codasi = RsAux("cod_asi")
                Nombreasig = RsAux("nom_asi")
                
                
                'pregunta si subsector es ingles
'                If Val(Sector) = 14 And Val(Codasi) = 8 And Val(Ngrado) >= 1 And Val(Ngrado) <= 4 And CodModalidad = "110" Then
'                    inglesvar = 1
'                Else
                    inglesvar = 0
'                End If
                
                
                'pregunta para dejar el recuadro de las notas con sangria
                If (val(Ngrado) = 7 Or val(Ngrado) = 8) And (val(Sector) = 7 And (val(Codasi) = 3 Or val(Codasi) = 8 Or val(Codasi) = 7)) Then
                    Printer.Line (400, CLng(y1))-(11500, CLng(y1 + 400)), , B '**Recuadro horizontal notas**
                    especial = 1
                Else
                    Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 400)), , B '**Recuadro horizontal notas**
                    especial = 0
                End If
                
                rsnotas.Open "select cod_sec, cod_asi, num_per, cod_eva, nota from notas where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "' and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and num_per = '" & numperiodo & "' and agno = " & cmb_agno.Text & " order by cod_sec, cod_asi", conn
                If rsnotas.RecordCount > 0 Then
                    notass2 = rsnotas("nota")
                End If
                Aumentosector = Aumentosector + 400
                Printer.CurrentY = 4080 'Altura donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
'
                If especial = 1 Then
                    Printer.CurrentX = 500
                Else
                    Printer.CurrentX = 100
                End If
                
                Printer.FontSize = 8
                Printer.Print (Nombreasig) 'Imprimo nombre asignatura
                
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 410
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Or (val(Sector) = 3 And val(Codasi) = 20) Then
                    notas = rsnotas("nota")
                    
                    If (val(Sector) = 3 And val(Codasi) = 20) Then
'                       posy = 5700
                       posx = 10700
                       posy = Printer.CurrentY
                    End If
                    
                    For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408 'separacion horizontal de notas
                                
                        Printer.CurrentX = 3300 'Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                 
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                            
                            
                            'acumula nota leng
                         If val(Sector) = 14 And val(Codasi) = 14 Then
                                    promleng = promleng + notasincoma
                         End If
                         
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0")) 'aqui debo dejar un numero entero 4 como 4,0
                        End If 'sin necesidad de agregarle coma como texto
                        Divisor = Divisor + 1
                    Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        
                        'si el ramo es ingles guarda la nota ORDENAMIENTO
                If (val(Sector) = 14 And val(Codasi) = 8) Then
                                notass = notass2
                        m1 = 10
                        For a = 1 To 12
                           If val(Mid(notas, (a * 2) - 1, 2)) <> 0 Then
                           If CInt(m1) < CInt(Mid(notas, (a * 2) - 1, 2)) Then
                              m1 = Mid(notas, (a * 2) - 1, 2)
                              p1 = a
                           End If
                           End If
                        Next a
                        
                        m2 = 10
                        For a = 1 To 12
                           If val(Mid(notas, (a * 2) - 1, 2)) <> 0 Then
                           If CInt(m2) < CInt(Mid(notas, (a * 2) - 1, 2)) And a <> p1 Then
                              m2 = Mid(notas, (a * 2) - 1, 2)
                              p2 = a
                           End If
                           End If
                        Next a
                        
                        m3 = 10
                        For a = 1 To 12
                           If val(Mid(notas, (a * 2) - 1, 2)) <> 0 Then
                           If CInt(m3) < CInt(Mid(notas, (a * 2) - 1, 2)) And a <> p1 And a <> p2 Then
                              m3 = Mid(notas, (a * 2) - 1, 2)
                              p3 = a
                           End If
                           End If
                        Next a
                        
                        'Estas son las 3 notas mayores
                        mayor1 = m1
                        mayor2 = m2
                        mayor3 = m3
                        
                        inglesprom = mayor1 + mayor2 + mayor3
                                
                End If
                
                        'si el ramo es compresion del medio no imprime notas debido a que este seria solo un encanbezado
                        'If (Val(Ngrado) = 7 Or Val(Ngrado) = 8) And (Val(Sector) = 3 And Val(Codasi) = 20) Then
                       'Else
                            'imprime notas
                        If rsnotas("cod_asi") = 13 Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = 13 and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                'Printer.Print ("Ex.")
                            Else
                                Printer.Print (Nota)
                            End If
                        Else
                            Printer.Print (Nota)
                        End If
                            
                            
                            
                           ' Printer.Print (Nota)
                        'End If
                        
                        Printer.FontBold = False
                        
'                    If Val(Sector) = 14 And Val(Codasi) = 14 Then
'                        tnotasl = tnotas
'                    End If
                    Next tnotas
                    
                    If val(Sector) = 14 And val(Codasi) = 14 Then
                        tnotasl = ((Len(notas)) / 2)
                    End If
                    
                    End If
                End If
                rsnotas.Close
            
'CONSULTA PROMEDIO ASIGNATURA
If numperiodo = 0 Then
    rsnotas.Open "select REPLACE(mid(SUM(p1)/COUNT(p1),1,3), '.', ',') as pro from promedios where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "' and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and agno = " & cmb_agno.Text & " and p1 <> 0 order by cod_sec, cod_asi", conn
Else
    rsnotas.Open "select REPLACE(mid(SUM(p2)/COUNT(p2),1,3), '.', ',') as pro from promedios where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "' and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and agno = " & cmb_agno.Text & " and p2 <> 0 order by cod_sec, cod_asi", conn
End If
    
    If Not IsNull(rsnotas("pro")) Then
        pro = rsnotas("pro")
    Else
        pro = ""
    End If
    
    rsnotas.Close
'FIN CONSULTA PROMEDIO ASIGNATURA
                
                rsnotas.Open "select * from promedios where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and agno = " & cmb_agno.Text & " order by cod_sec, cod_asi", conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10700 'ubicacion notas promedio
                    If numperiodo = 0 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    If Nota < 4# Then
                        Printer.FontBold = False
                    Else
                        Printer.FontBold = False
                    End If
                                                        
                    
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    
                    Select Case CSng(val(pro))
                            Case 0 To 0.9
                                procur = "EX"
                            Case 1# To 3.9
                                procur = "I"
                            Case 4# To 4.9
                                procur = "S"
                            Case 5# To 5.9
                                procur = "B"
                            Case 6# To 7#
                                procur = "MB"
                    End Select
                    
                    If rsnotas("cod_asi") <> 13 Then
                        If val(Replace(Nota, ",", ".")) <> "0,0" Then
                                'If Not ((rsnotas("cod_asi") = 8) And CodModalidad = "110") And Not ((rsnotas("cod_asi") = 5 Or rsnotas("cod_asi") = 6 Or rsnotas("cod_asi") = 7) And CodModalidad = "110") Then
                                    cont = cont + 1
                                    prom = prom + val(Replace(Nota, ",", "."))
                                'End If
                                If Me.opt_final_parcial(0) Then
                            
                                'si ramo es ingles
                                If inglesvar = 1 And val(Ngrado) >= 1 And val(Ngrado) <= 4 And CodModalidad = "110" Then
                                    'imprime promedio lenguaje
                                    Printer.CurrentY = 4500
                                    Printer.CurrentX = 10700
                                    
                                    
                                    If numperiodo = 1 Then
                                        inglesprom = promleng / tnotasl
                                    Else
                                        inglesprom = (promleng + inglesprom) / (tnotasl + 3)
                                    End If
                                    
                                    'inglesprom = (promleng + inglesprom) / (tnotasl + 3)
                                    c_n = inglesprom '(Mid(especial_prom / 3, 1, 3))
                                    sw = 1
                                    
                                    If Len(inglesprom) > 1 Then
                                        Printer.Print (Mid(inglesprom, 1, 1)) & "," & (Mid(inglesprom, 2, 1))
                                    Else
                                        Printer.Print inglesprom & ",0"
                                    End If
                            
                                Else
                                    'si lenguaje ( aqui se imprimen los dos promedios)
                                    If val(Sector) = 14 And val(Codasi) = 14 And val(Ngrado) >= 1 And val(Ngrado) <= 4 And CodModalidad = "110" Then
                                        Printer.Print (Nota) & "     " & (pro)
                                    Else
                                        If especial = 1 Then
                                            especial_prom = especial_prom + Nota
                                            especial_promc = especial_promc + pro
                                        Else
                                            Printer.Print (Nota) & "    " & (pro)
                                        End If
                                    End If
                                End If
                                    
                                    
                                End If
                        Else
                        Printer.Print ("       ") & "    " & (pro)
                        End If
                    Else
                    
                        If Me.opt_final_parcial(0) Then
                        If rsnotas("cod_asi") = 13 Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = 13 and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                Printer.Print ("Ex.") & "     " & (procur)
                            Else
                                'Printer.Print (Nota)
                                If Promsemestre <> "EX" Then
                                    Printer.Print (Promsemestre) & "     " & (procur)
                                Else
                                    If procur <> "EX" Then
                                        Printer.Print "     " & "     " & (procur)
                                    End If
                                    
                                End If
                            End If
                        Else
                            'Printer.Print (Nota)
                            Printer.Print (Promsemestre) & "     " & (procur)
                            'Printer.Print "    " & (procur)
                        End If
                        
                            'Printer.Print (Promsemestre) & "    " & (procur)
                            
                        End If
                        
                        
                        'imprime naturales
                        If posy <> 0 Then
                            Printer.CurrentY = posy
                            Printer.CurrentX = posx
                        If Ngrado = 7 Or Ngrado = 8 Then
                            If Len(Mid(especial_prom / 3, 1, 3)) <> 1 Then
                                'Printer.Print (Mid(especial_prom / 3, 1, 3)) & "    " & (Mid(especial_promc / 3, 1, 3))
                                c_n = (Mid(especial_prom / 3, 1, 3))
                                sw = 1
                            Else
                                'Printer.Print (Mid(especial_prom / 3, 1, 3)) & ",0    " & (Mid(especial_promc / 3, 1, 3))
                                c_n = (Mid(especial_prom / 3, 1, 3))
                                sw = 1
                            End If
                        End If
                        End If
                        
                       
                        
                    End If
                    Printer.FontBold = False
                    
                End If

                rsnotas.Close
                RsAux.MoveNext
            Wend
                     
            
                        
            Printer.Line (3660, 3900)-(3650, y1 + 400)   '**Linea vertical primera para notas**
            Printer.Line (10600, 3900)-(10600, y1 + 400) '**Linea vertical separador promedio notas**
            Printer.Line (11050, 3900)-(11050, y1 + 400) '**Linea vertical separador promedio curso**
            
            For y2 = 1 To 17
                Printer.Line (3660 + (408 * y2), 3900)-(3660 + (408 * y2), y1 + 400) '**Linea vertical separador notas**
            Next y2

        'ultimo rcuadro
            y1 = y1 + 400 'toma valor de y y se separa
            Printer.Line (50, CLng(y1 + 100))-(11500, CLng(y1 + 500)), , B 'RECUADRO PROMEDIO FINAL
            Printer.CurrentY = y1 + 250
            Printer.CurrentX = 8000
            Printer.FontSize = 8
            Printer.Print "PROMEDIO FINAL DEL PERIODO" ' Imprimo asignatura
            Printer.CurrentY = y1 + 250
            Printer.CurrentX = 10950
            Dim NotaFinalInf As String
            If cont <> 0 Then
                If sw = 1 Then
                    If val(Ngrado) >= 1 And val(Ngrado) <= 4 And CodModalidad = "110" Then
                    c_n = c_n / 10
                    End If
                    
                    'prom = prom + c_n
                    'cont = cont + 1
                End If
                
                NotaFinalInf = Trim(str(prom / cont))
                
            End If
            NotaFinalInf = Mid(NotaFinalInf, 1, 1) & "," & val(Mid(NotaFinalInf, 3, 1))
            If val(NotaFinalInf) < 4 Then
                Printer.FontBold = True
            Else
                Printer.FontBold = False
            End If
            If Me.opt_final_parcial(0) Then
                If NotaFinalInf <> ",0" Then
                    Printer.Print (NotaFinalInf)
                End If
            End If
            Printer.FontBold = False
    End If
    RsAux.Close
    
'TALLERES CURRICULARES
    var_sql = "select * from talleres where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and tipo_tall = 1"
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
    
        y1 = y1 + 500
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 100
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print ("T A L L E R E S    C U R R I C U L A R E S")
        Printer.FontBold = False

        rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
        
            ydeproceso = ydeproceso + 400
            y3 = y1 + 400
            While Not RsAux.EOF
                y1 = y1 + 400
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 400)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
   
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 400
                Printer.CurrentY = Y4 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 400
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
         
                    For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0"))
                        End If 'sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        Printer.Print (Nota)
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                                      
                rsnotas.Open var_sql, conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If (numperiodo + 1) = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                
                'prefunta primer ciclo MODIFICAR
                'If (CodModalidad <> 110) And (Ngrado <> 1 And Ngrado <> 2 And Ngrado <> 3 And Ngrado <> 4) Then
                    If (cod_tall = 17 Or cod_tall = 18 Or cod_tall = 19 Or cod_tall = 20) And CodModalidad = "110" Then
                        Printer.Print (Nota)
                    Else
                        Printer.Print (Promsemestre)
                    End If
                'End If
                'fin pregunta primer ciclo
                
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If

                rsnotas.Close
                RsAux.MoveNext
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 400)   'linea vertical
            Printer.Line (10600, CInt(y3))-(10600, y1 + 400) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 400) 'linea vertical
            Next y2
    End If
    RsAux.Close
    
    var_sql = "select * from talleres t,alumnos_talleres at" _
            & " where at.ci_alu = '" & rutalumno & "' and t.cod_ens = at.cod_ens" _
            & " and t.cod_tall = at.cod_tall" _
            & " and t.num_gra = at.numgra and t.tipo_tall = at.tipo_tall" _
            & " and at.let_cur = '" & letra & "' and at.cod_ens = '" & CodModalidad & "'" _
            & " and at.numgra = '" & Ngrado & "' and t.tipo_tall = 2 and agno = " & cmb_agno.Text
            
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
        y1 = y1 + 400
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 200
    
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print "T A L L E R E S    L I B R E    ELECCIÓN"
        Printer.FontBold = False

        rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
            ydeproceso = ydeproceso + 400
            y3 = y1 + 400
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 400)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
                      
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = Y4 'Donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 400
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
                    
            For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0")) 'Round(CDec(Val(Nota * 1.01)), 1) ' aqui debo dejar un numero entero 4 como 4,0
                        End If ' sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        Printer.Print (Nota)
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                              
                rsnotas.Open var_sql, conn
            If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If numperiodo + 1 = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                    Printer.Print (Promsemestre)
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If
                rsnotas.Close
                RsAux.MoveNext
               
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 400) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 400) 'linea vertical
            Next y2
            Printer.Line (10600, CInt(y3))-(10600, y1 + 400)
    End If
    RsAux.Close
    
'TALLERES CURRICULARES

End Function

Sub Imprimeencabezadopant_tall()
Dim colegio As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
Dim var_sql As String
var_sql = "select valor from cfg where param = 'codbc'"
objRS.Open var_sql, conn
colegio = objRS("valor")
objRS.Close

var_sql = "select month(now()) as mes"
objRS.Open var_sql, conn
mes = objRS("mes")
objRS.Close

Call encabezadopapel(True)
'If Me.opt_final_parcial(0) Then
'    Tipoinforme = "INFORME FINAL DE NOTAS"
'ElseIf Me.opt_final_parcial(1) Then
'    Tipoinforme = "INFORME PARCIAL DE NOTAS"
'End If

numperiodo = aperiodos(Me.lst_periodos.ListIndex)

If numperiodo = 0 Then
If mes > 6 Then
    Tipoinforme = "INFORME FINAL DE NOTAS"
Else
    Tipoinforme = "INFORME PARCIAL DE NOTAS"
End If
End If

'If numperiodo = 1 Then
'If Mes > 11 Then
'    Tipoinforme = "INFORME FINAL DE NOTAS"
'Else
Tipoinforme = "INFORME DE NOTAS"
'End If
'End If

Printer.FontSize = 9
If colegio = "FLO001" And cmb_agno.Text = 2021 Then
    Call centrarenpapel(1000, Tipoinforme & " " & Mid(lst_periodos.Text, 1, (Len(lst_periodos.Text) - 9)) & "TRIMESTRE" & " " & cmb_agno.Text)
Else
    If colegio = "FLO001" Then
        Call centrarenpapel(1000, Tipoinforme & " " & IIf(lst_periodos.Text = "PRIMER TRIMESTRE", "PRIMER SEMESTRE", "SEGUNDO SEMESTRE") & " " & cmb_agno.Text)  ' Este año debe ser el de proceso NO DEL SISTEMA
    Else
        Call centrarenpapel(1000, Tipoinforme & " " & lst_periodos.Text & " " & cmb_agno.Text)    ' Este año debe ser el de proceso NO DEL SISTEMA
    End If
End If
Printer.FontSize = 8

If colegio <> "LIN001" Then
    'Printer.PaintPicture LoadPicture("\\192.168.7.101\logo\aguilita.gif"), 10000, 880
Else
    Printer.PaintPicture LoadPicture("c:\Archivos de programa\Ges_Col\objetos\insignia_lincoln.gif"), 10000, 880
End If

Printer.CurrentX = 100: Printer.CurrentY = 1400: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 1400: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 1600: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 1600: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 1800: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 1800: Printer.Print (":")
Printer.FontBold = False
Printer.Line (50, 2500)-(11500, 3000), , B  ' ESTE ES EL PRIMER BOX DEL INFORME
Printer.FontBold = True
Printer.FontSize = 10
Printer.CurrentX = 100: Printer.CurrentY = 2650: Printer.Print ("A S I G N A T U R A S")
Printer.FontBold = False
Printer.FontSize = 8
Aumento = 0
Printer.FontSize = 8
For t = 1 To 17
    Aumento = Aumento + 350 + 52
    Printer.CurrentX = 3400
    Printer.CurrentX = Printer.CurrentX + Aumento
    Printer.CurrentY = 2750
    Printer.Print (t)
Next t
Printer.CurrentX = 10700: Printer.CurrentY = 2550: Printer.Print ("Promedio")
Printer.CurrentX = 10690: Printer.CurrentY = 2700: Printer.Print ("Semestre")
    Printer.Line (3650, 2500)-(3650, 3100), , B         ' linea vertical
    Printer.Line (10600, 2500)-(10600, 3100), , B    ' linea vertical
End Sub

Function Imprimenotasalumnopant_tall(rutalumno As String, Ngrado As String, letra As String, CodModalidad As String, NombreModalidad As String, numperiodo As String) As Long
 '   On Error Resume Next
    Dim Promsemestre As String
    Dim procur As String
    Dim y1, y2, y3, cont, prom As Double
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    Dim rsnotas As ADODB.Recordset
    Set rsnotas = New ADODB.Recordset
    Dim especial_prom As Double
    Dim especial_cont As Integer
    Dim especial As Integer
    
    '
    Dim Promproceso As Single, Promponderado As Single, valnota As Single   'notasincoma As Single, nota As Single,
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    Printer.FontSize = 8
    Printer.CurrentX = 1600: Printer.CurrentY = 1400: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1600: Printer.CurrentY = 1600: Printer.Print (Ngrado & " " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1600: Printer.CurrentY = 1800: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    Dim RsAux As ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    RsAux.CursorLocation = adUseClient
'    var_sql = "select *" _
'            & " from subsectores s,asi_x_cur_prof ap" _
'            & " where s.num_gra = ap.num_gra and s.cod_asi = ap.cod_asi and s.cod_ens = ap.cod_ens and" _
'            & " ap.cod_ens = '" & CodModalidad & "' and ap.num_gra = '" & Ngrado & "' and ord_asi <> 0 and ap.let_cur = '" & Letra & "'" _
'            & " and agno = " & Cmb_Agno.Text & " order by ord_asi"
'Volver atras
    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
    'var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and ci_alu = '" & rutalumno & "' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
    'se modifica 25-08-2022
        var_sql = ""
        var_sql = var_sql & " SELECT * FROM"
        var_sql = var_sql & " (SELECT * FROM subsectores WHERE cod_ens = '" & CodModalidad & "' AND num_gra =  '" & Ngrado & "' AND ord_asi <> 0"
        var_sql = var_sql & " AND concat(cod_sec,cod_asi) IN (SELECT concat(cod_sec,cod_asi) FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "'"
        var_sql = var_sql & " AND letra_curso =  '" & letra & "'  AND num_per = '0' AND ci_alu = '" & rutalumno & "' AND nota <> '' AND agno = '" & Anno & "')"
        var_sql = var_sql & " AND asi_elec = 'N'"
        var_sql = var_sql & " Union"
        var_sql = var_sql & " SELECT * FROM subsectores WHERE cod_ens = '" & CodModalidad & "' AND num_gra =  '" & Ngrado & "' AND ord_asi <> 0"
        var_sql = var_sql & " AND cod_asi IN (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra =  '" & Ngrado & "' AND asi_elec = 'S'"
        var_sql = var_sql & " AND letra_curso =  '" & letra & "'  AND num_per = '0' AND ci_alu = '" & rutalumno & "' AND nota <> '' AND agno = '" & Anno & "')"
        var_sql = var_sql & " AND cod_asi IN (SELECT cod_asi FROM asignaturas_electivas WHERE cod_ens = '" & CodModalidad & "' AND num_gra =  '" & Ngrado & "' AND ci_alu = '" & rutalumno & "')) AS asig"
        var_sql = var_sql & " ORDER BY ord_asi"
    
    
    Else
    var_sql = "select * from (select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and concat(cod_sec,cod_asi) in (SELECT concat(cod_sec,cod_asi) FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and agno = '" & Anno & "' and nota <> '')" _
            & " union select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and concat(cod_sec,cod_asi) in (SELECT concat(cod_sec,cod_asi) FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and agno = '" & Anno & "' and concat(cod_sec,cod_asi) = '00116')) as a order by ord_asi"
    'var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 ORDER BY ord_asi"
    ' SELECT * FROM subsectores WHERE cod_ens = '110' AND num_gra = '5' AND ord_asi <> 0 AND cod_asi IN (SELECT cod_asi FROM asi_x_cur_prof WHERE cod_ens = '110' AND num_gra = '5' AND let_cur = 'A' AND agno = '2023') ORDER BY ord_asi
    
    End If
'''    'Ahora se muestran todos las asignaturas aunque no estan ingresadas notas
'''    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
'''    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi ORDER BY ord_asi"
'''    Else
'''    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi ORDER BY ord_asi"
'''    End If
    
    cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
    RsAux.Open var_sql, conn
    'Aqui acabo de seleccionar los sectores y asignaturas
    'correspondientes al nivel del alumno.
    promfinal = 0: Sumapromedios = 0
    If RsAux.RecordCount > 0 Then 'Si se encontraron asignaturas en el curso
        'Dim rsnotas As ADODB.Recordset
        Set rsnotas = New ADODB.Recordset
        'rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        y1 = 2500
        prom = 0
        cont = 0
            ydeproceso = 2680
            While Not RsAux.EOF
                y1 = y1 + 500
                
               ' Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B 'ESTE ES EL PRIMER BOX DEL INFORME
                
                Sector = RsAux("cod_sec")
                Codasi = RsAux("cod_asi")
                Nombreasig = RsAux("nom_asi")
                
                ''''''pregunta para dejar el recuadro de las notas con sangria
                
                If cole = "LON001" Or cole = "SNM001" Or cole = "FLO001" Or cole = "FAR001" Then
                    If ((val(Ngrado) = 1 Or val(Ngrado) = 2) And CodModalidad = "310") And (val(Sector) = 11 And val(Codasi) = 3 Or val(Codasi) = 8 Or val(Codasi) = 7) Then
                        Printer.Line (500, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                        especial = 1
                    Else
                        Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                        especial = 0
                    End If
                Else
                    If (val(Ngrado) = 1 And CodModalidad = "310") And (val(Sector) = 11 And val(Codasi) = 3 Or val(Codasi) = 8 Or val(Codasi) = 7) Then
                        Printer.Line (500, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                        especial = 1
                    Else
                        Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                        especial = 0
                    End If
                End If
                
                rsnotas.Open "select cod_sec, cod_asi, num_per, cod_eva, nota from notas where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and num_per = '" & numperiodo & "' and agno = " & cmb_agno.Text & " order by cod_sec, cod_asi", conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = 2580 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                                
                '                Printer.CurrentX = 100
                '''''' Campo especial
                If especial = 1 Then
                    Printer.CurrentX = 500
                Else
                    Printer.CurrentX = 100
                End If
                
                Printer.FontSize = 8
                Printer.Print (Nombreasig) ' Imprimo asignatura
                
                Printer.CurrentY = 2780 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 1000
                Printer.FontSize = 6
                'Printer.Print "APRENDIZAJE        100%" 'Imprimo asignatura
                
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                '''' modifico if
                    If val(rsnotas("nota")) <> 0 Or (val(Sector) = 11 And val(Codasi) = 6) Then
                    notas = rsnotas("nota")
                    
'''''''                    '''''' Posicion naturales
                    If (val(Sector) = 11 And val(Codasi) = 6) Then
                       posy = 5700
                       posx = 10700 + 250
                       posy = Printer.CurrentY
                    End If
                    
                    For tnotas = 1 To 24 Step 2
                    'For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            If notasincoma <> " P" And notasincoma <> " p" Then
                                Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                                valnota = valnota + Nota
                            Else
                                Nota = notasincoma
                            End If
                                    If especial = 1 Then
                                            especial_prom = especial_prom + Nota
                                            especial_cont = especial_cont + 1
                                            'especial_promc = especial_promc + pro
                                    Else
                                            'Printer.Print (Nota)
                                    End If
                            
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0"))
                        End If 'sin necesidad de agregarle coma como texto.
                        If Nota <> " P" And Nota <> " p" Then
                            Divisor = Divisor + 1
                        End If
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        
                        If rsnotas("cod_asi") = 13 Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = 13 and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                'Printer.Print ("Ex.")
                            Else
                                Printer.Print (Nota)
                            End If
                        Else
                            Printer.Print (Nota)
                        End If
                                                
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                
                
                rsnotas.Open "select * from promedios where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and agno = " & cmb_agno.Text & " order by cod_sec, cod_asi", conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If numperiodo = 0 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        If numperiodo = 1 Then
                            Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                        Else
                            Nota = Mid(rsnotas("p3"), 1, 1) & "," & val(Mid(rsnotas("p3"), 3, 1))
                        End If
                    End If
                    
                    If Nota < 4# Then
                        Printer.FontBold = False
                    Else
                        Printer.FontBold = False
                    End If
                    Promsemestre = ""
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    
                    If Not (rsnotas("cod_asi") = 13 Or rsnotas("cod_asi") = 22) Then
                        var_sql = "select if(count(*)>0,'SI','NO') as ex from promedios p,acta_alumexi a" _
                                & " where p.ci_alu = a.run_alu and p.cod_asi = a.cod_asi and p.ci_alu = '" & rutalumno & "'" _
                                & " and p.cod_asi = '" & rsnotas("cod_asi") & "' and a.agno = " & cmb_agno.Text _
                                & " and p.agno = a.agno"
                        objRS.Open var_sql, conn
                        exi = objRS("ex")
                        objRS.Close
                        If exi = "NO" Then
                            If val(Replace(Nota, ",", ".")) <> "0,0" Then
                                ''''' No sumar biologia quimica fisica
                                If cole = "LON001" Or cole = "SNM001" Or cole = "FLO001" Or cole = "FAR001" Then
                                    If Not ((rsnotas("cod_asi") = 3 Or rsnotas("cod_asi") = 8 Or rsnotas("cod_asi") = 7) And CodModalidad = "310" And (Ngrado = 1 Or Ngrado = 2)) Then
                                        cont = cont + 1
                                        prom = prom + val(Replace(Nota, ",", "."))
                                        Printer.Print (Nota)
                                    End If
                                Else
                                    If Not ((rsnotas("cod_asi") = 3 Or rsnotas("cod_asi") = 8 Or rsnotas("cod_asi") = 7) And CodModalidad = "310" And Ngrado = 1) Then
                                        cont = cont + 1
                                        prom = prom + val(Replace(Nota, ",", "."))
                                        Printer.Print (Nota)
                                    End If
                                End If
                                
                                If Me.opt_final_parcial(0) Then
                                         '''' Promedio especial
'''                                    If especial = 1 Then
'''                                            especial_prom = especial_prom + Nota
'''                                            'especial_promc = especial_promc + pro
'''                                    Else
   '                                         Printer.Print (Nota)
'''                                    End If
                                    
                         '           Printer.Print (Nota)
                                End If
                            End If
                        Else
                            Printer.Print ("Ex.")
                        End If
                        
                        
                    Else
                        If Me.opt_final_parcial(0) Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = " & rsnotas("cod_asi") & " and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                Printer.Print ("Ex.")
                            Else
                                If (rsnotas("cod_asi") = "13" And Promsemestre = "EX") Or Nota = "0,0" Then
                                Else
                           
                                Printer.Print (Promsemestre)
                                End If
                            End If
                        End If
                    End If
                    Printer.FontBold = False
                    
                End If
                        ''''imprime naturales
                        If posy <> 0 Then
                            '''''guardo coordenadas
                            poy = Printer.CurrentY
                            pox = Printer.CurrentX
                            Printer.CurrentY = posy
                            Printer.CurrentX = posx
                        If cole = "LON001" Or cole = "SNM001" Or cole = "FLO001" Or cole = "FAR001" Then
                            If (CodModalidad = "310" And (Ngrado = 1 Or Ngrado = 2)) And val(Codasi) = 6 And especial_prom <> 0 Then
                        
                                If Len(Mid(especial_prom / especial_cont, 1, 3)) <> 1 Then
                                    'Printer.Print (Mid(especial_prom / 3, 1, 3)) & "    " & (Mid(especial_promc / 3, 1, 3))
                                   ' c_n = (Mid(especial_prom / especial_cont, 1, 3))
                                    c_n = (Mid((especial_prom / especial_cont) + 0.04, 1, 3))
                                    sw = 1
                                    Printer.Print (c_n)
                                Else
                                    'Printer.Print (Mid(especial_prom / 3, 1, 3)) & ",0    " & (Mid(especial_promc / 3, 1, 3))
                                    'c_n = (Mid(especial_prom / especial_cont, 1, 3))
                                    c_n = (Mid((especial_prom / especial_cont) + 0.04, 1, 3))
                                    sw = 1
                                    Printer.Print (c_n & ",0")
                                End If
                                '''asigno coordenadas
                                Printer.CurrentY = poy
                                Printer.CurrentX = pox
                            End If
                        
                        Else
                            If (CodModalidad = "310" And (Ngrado = 1)) And val(Codasi) = 6 And especial_prom <> 0 Then
                        
                                If Len(Mid(especial_prom / especial_cont, 1, 3)) <> 1 Then
                                    'Printer.Print (Mid(especial_prom / 3, 1, 3)) & "    " & (Mid(especial_promc / 3, 1, 3))
                                    'c_n = (Mid(especial_prom / especial_cont, 1, 3))
                                    c_n = (Mid((especial_prom / especial_cont) + 0.04, 1, 3))
                                    sw = 1
                                    Printer.Print (c_n)
                                Else
                                    'Printer.Print (Mid(especial_prom / 3, 1, 3)) & ",0    " & (Mid(especial_promc / 3, 1, 3))
                                    'c_n = (Mid(especial_prom / especial_cont, 1, 3))
                                    c_n = (Mid((especial_prom / especial_cont) + 0.04, 1, 3))
                                    sw = 1
                                    Printer.Print (c_n & ",0")
                                End If
                                '''asigno coordenadas
                                Printer.CurrentY = poy
                                Printer.CurrentX = pox
                            End If
                        End If
                        End If

                rsnotas.Close
                RsAux.MoveNext
            Wend
                        
            Printer.Line (3650, 2700)-(3650, y1 + 500)   'linea vertical
            Printer.Line (10600, 2700)-(10600, y1 + 500) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), 2500)-(3650 + (408 * y2), y1 + 500) 'linea vertical
            Next y2
            Printer.Line (3250 + (408 * y2), y1 + 600)-(3250 + (408 * y2), y1 + 1000) 'linea vertical
            Printer.Line (10600, y1 + 600)-(10600, y1 + 1000) 'linea vertical
            
            y1 = y1 + 500
            Printer.Line (50, CLng(y1 + 100))-(11500, CLng(y1 + 500)), , B
            Printer.CurrentY = y1 + 250
            
            Printer.FontSize = 8
            Printer.CurrentX = 100
            'Printer.CurrentY = y1 + 250
            'Asistencia
            'rutalumno nombre de campo
            
            var_sql = "SELECT ci_alu,a.mes_asis,asi_r,asi_t,(100 * SUM(asi_t))/SUM(asi_r) AS porcentaje FROM asistencia a,fnza_conversion_meses c" _
                    & " WHERE a.mes_asis = c.abv_mes AND c.num_mes <= DATE_FORMAT(NOW(),'%m') AND agno = " & cmb_agno.Text & " AND ci_alu = '" & rutalumno & "'" _
                    & " GROUP BY ci_alu"
            objRS.Open var_sql, conn
            If objRS.RecordCount > 0 Then
                If objRS("porcentaje") = 100 Then
                    Printer.Print "Porcentaje de Asistencia: " & Format(objRS("porcentaje"), "0.0") & "%                                                                                                                            PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
                Else
                    Printer.Print "Porcentaje de Asistencia: " & Format(objRS("porcentaje"), "0.0") & "%                                                                                                                              PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
                End If
            Else
                Printer.Print "Porcentaje de Asistencia:                                                                                                                                      PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
            End If
            objRS.Close
                      
            
            Printer.CurrentX = 8000
            Printer.FontSize = 8
            'Printer.Print "PROMEDIO FINAL DEL PERIODO" 'Imprimo asignatura
            Printer.CurrentY = y1 + 250
            Printer.CurrentX = 10950
            Dim NotaFinalInf As String
            If prom <> 0 And cont <> 0 Then
                '''' Promedio si es ciencias naturales
                If cole = "LON001" Or cole = "SNM001" Or cole = "FLO001" Or cole = "FAR001" Then
                    If (val(Ngrado) = 1 Or val(Ngrado) = 2) And CodModalidad = "310" And c_n <> 0 Then
                        If cole = "FLO001" Then
                            NotaFinalInf = (prom + c_n) / (cont + 1) + 0.05
                        Else
                            NotaFinalInf = Trim(str((prom + c_n) / (cont + 1)))
                        End If
                    Else
                        If cole = "FLO001" Then
                            NotaFinalInf = (prom / cont) + 0.05
                        Else
                            NotaFinalInf = Trim(str(prom / cont))
                        End If
                    End If
                Else
                    If (val(Ngrado) = 1) And CodModalidad = "310" And c_n <> 0 Then
                        NotaFinalInf = Trim(str((prom + c_n) / (cont + 1)))
                    Else
                        NotaFinalInf = Trim(str(prom / cont))
                    End If
                End If
            Else
                NotaFinalInf = 0
            End If
            
            cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
            If cole = "LIN001" Then
                If prom <> 0 And cont <> 0 Then
                    NotaFinalInf = (prom / cont) + 0.05
            Else
                    NotaFinalInf = 0
            End If
            End If
            
            NotaFinalInf = Mid(NotaFinalInf, 1, 1) & "," & val(Mid(NotaFinalInf, 3, 1))
            If val(NotaFinalInf) < 4 Then
                Printer.FontBold = True
            Else
                Printer.FontBold = False
            End If
            If Me.opt_final_parcial(0) Then
                If NotaFinalInf <> "0,0" Then
                    'Printer.Print (NotaFinalInf)
                     If NotaFinalInf <> ",0" Then
                        Printer.Print (NotaFinalInf)
                     End If
                End If
            End If
            Printer.FontBold = False
    End If
    RsAux.Close
    
    
'TALLERES CURRICULARES
    var_sql = "select * from talleres, notas_talleres where talleres.cod_ens = '" & CodModalidad & "' and talleres.num_gra = '" & Ngrado & "' and talleres.tipo_tall = 1 and notas_talleres.agno = " & cmb_agno.Text & " and notas_talleres.ci_alu = '" & rutalumno & "' and notas_talleres.num_per = " & (numperiodo + 1) & " And talleres.Cod_Ens = notas_talleres.Cod_Ens and talleres.NUM_GRA = notas_talleres.NUM_GRA AND talleres.TIPO_TALL = notas_talleres.TIPO_TALL AND talleres.COD_TALL = notas_talleres.COD_TALL"
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
    
        y1 = y1 + 500
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 200
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print ("T A L L E R E S    C U R R I C U L A R E S")
        Printer.FontBold = False

        'rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
            ydeproceso = ydeproceso + 500
            y3 = y1 + 500
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
   
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = Y4 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
         
                    For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0"))
                        End If 'sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        If Nota <> "0.0" Then
                            Printer.Print (Nota) 'La notas sale sin problemas
                        End If
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                                      
                rsnotas.Open var_sql, conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If (numperiodo + 1) = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 2, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 2, 1))
                    End If
                    

                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    
                    
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                    
'                    If colegio = "FAR001" Then
'                        Printer.Print (Nota)
'                    Else
                    
                        Printer.Print (Promsemestre)
'                    End If
                    
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If
                '
                rsnotas.Close
                RsAux.MoveNext
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 500)   'linea vertical
            Printer.Line (10600, CInt(y3))-(10600, y1 + 500) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 500) 'linea vertical
            Next y2
    End If
    RsAux.Close
    
    var_sql = "select * from talleres t,alumnos_talleres at" _
            & " where at.ci_alu = '" & rutalumno & "' and t.cod_ens = at.cod_ens" _
            & " and t.cod_tall = at.cod_tall" _
            & " and t.num_gra = at.numgra and t.tipo_tall = at.tipo_tall" _
            & " and at.let_cur = '" & letra & "' and at.cod_ens = '" & CodModalidad & "'" _
            & " and at.numgra = '" & Ngrado & "' and t.tipo_tall = 2 and agno = " & cmb_agno.Text
            
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
        y1 = y1 + 500
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 200
    
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print "T A L L E R E S    L I B R E    ELECCIÓN"
        Printer.FontBold = False

       ' rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
            ydeproceso = ydeproceso + 500
            y3 = y1 + 500
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
                      
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = Y4 'Donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
                    
            For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0")) 'Round(CDec(Val(Nota * 1.01)), 1) ' aqui debo dejar un numero entero 4 como 4,0
                        End If ' sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        Printer.Print (Nota)
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                              
                rsnotas.Open var_sql, conn
            If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If numperiodo + 1 = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                    
'                    If colegio = "FAR001" Then
'                        Printer.Print (Nota)
'                    Else
                        Printer.Print (Promsemestre)
                   ' End If
                    
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If
                rsnotas.Close
                RsAux.MoveNext
               
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 500) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 500) 'linea vertical
            Next y2
            Printer.Line (10600, CInt(y3))-(10600, y1 + 500)
    End If
    RsAux.Close
    Imprimenotasalumnopant_tall = y1
End Function


Function Imprimenotasalumnopant_tall_formativa(rutalumno As String, Ngrado As String, letra As String, CodModalidad As String, NombreModalidad As String, numperiodo As String, tipo_EVA As Integer) As Long
 '   On Error Resume Next
    Dim Promsemestre As String
    Dim procur As String
    Dim y1, y2, y3, cont, prom As Double
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    Dim rsnotas As ADODB.Recordset
    Set rsnotas = New ADODB.Recordset
    Dim especial_prom As Double
    Dim especial_cont As Integer
    Dim especial As Integer
    
    '
    Dim Promproceso As Single, Promponderado As Single, valnota As Single   'notasincoma As Single, nota As Single,
    nombres = DevuelveCampo("postulantes", "", "nom_alu", "ci_alu ='" & rutalumno & "'", conn)
    apaterno = DevuelveCampo("postulantes", "", "ape_pat_alu", "ci_alu ='" & rutalumno & "'", conn)
    amaterno = DevuelveCampo("postulantes", "", "ape_mat_alu", "ci_alu ='" & rutalumno & "'", conn)
    RutApo = DevuelveCampo("apo_x_alu", "", "rut_apo", "ci_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
    nombreapo = DevuelveCampo("apoderados", "", "noms_apo", "rut_apo ='" & RutApo & "'", conn)
    ape1apo = DevuelveCampo("apoderados", "", "ape1_apo", "rut_apo ='" & RutApo & "'", conn)
    ape2apo = DevuelveCampo("apoderados", "", "ape2_apo", "rut_apo ='" & RutApo & "'", conn)
    Printer.FontSize = 8
    Printer.CurrentX = 1600: Printer.CurrentY = 1400: Printer.Print (nombres & " " & apaterno & " " & amaterno)
    Printer.CurrentX = 1600: Printer.CurrentY = 1600: Printer.Print (Ngrado & " " & letra & " " & UCase(NombreModalidad))
    Printer.CurrentX = 1600: Printer.CurrentY = 1800: Printer.Print (nombreapo & " " & ape1apo & " " & ape2apo)
    Dim RsAux As ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    RsAux.CursorLocation = adUseClient
'    var_sql = "select *" _
'            & " from subsectores s,asi_x_cur_prof ap" _
'            & " where s.num_gra = ap.num_gra and s.cod_asi = ap.cod_asi and s.cod_ens = ap.cod_ens and" _
'            & " ap.cod_ens = '" & CodModalidad & "' and ap.num_gra = '" & Ngrado & "' and ord_asi <> 0 and ap.let_cur = '" & Letra & "'" _
'            & " and agno = " & Cmb_Agno.Text & " order by ord_asi"
'Volver atras
    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & letra & "' AND num_per = '0' and ci_alu = '" & rutalumno & "' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
    Else
    'var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi in (SELECT cod_asi FROM notas WHERE cod_ens = '" & CodModalidad & "' AND num_gra = '" & Ngrado & "' AND letra_curso = '" & Letra & "' AND num_per = '0' and nota <> '' and agno = '" & Anno & "') ORDER BY ord_asi"
    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 ORDER BY ord_asi"
    End If
'''    'Ahora se muestran todos las asignaturas aunque no estan ingresadas notas
'''    If CodModalidad = "310" And Ngrado >= "3" And Ngrado <= "4" Then
'''    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi ORDER BY ord_asi"
'''    Else
'''    var_sql = "select * from subsectores where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and ord_asi <> 0 and cod_asi ORDER BY ord_asi"
'''    End If
    
    cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
    RsAux.Open var_sql, conn
    'Aqui acabo de seleccionar los sectores y asignaturas
    'correspondientes al nivel del alumno.
    promfinal = 0: Sumapromedios = 0
    If RsAux.RecordCount > 0 Then 'Si se encontraron asignaturas en el curso
        'Dim rsnotas As ADODB.Recordset
        Set rsnotas = New ADODB.Recordset
        'rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        y1 = 2500
        prom = 0
        cont = 0
            ydeproceso = 2680
            While Not RsAux.EOF
                y1 = y1 + 500
                
               ' Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B 'ESTE ES EL PRIMER BOX DEL INFORME
                
                Sector = RsAux("cod_sec")
                Codasi = RsAux("cod_asi")
                Nombreasig = RsAux("nom_asi")
                
                ''''''pregunta para dejar el recuadro de las notas con sangria
                
                If cole = "LON001" Or cole = "SNM001" Or cole = "FLO001" Or cole = "FAR001" Then
                    If ((val(Ngrado) = 1 Or val(Ngrado) = 2) And CodModalidad = "310") And (val(Sector) = 11 And val(Codasi) = 3 Or val(Codasi) = 8 Or val(Codasi) = 7) Then
                        Printer.Line (500, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                        especial = 1
                    Else
                        Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                        especial = 0
                    End If
                Else
                    If (val(Ngrado) = 1 And CodModalidad = "310") And (val(Sector) = 11 And val(Codasi) = 3 Or val(Codasi) = 8 Or val(Codasi) = 7) Then
                        Printer.Line (500, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                        especial = 1
                    Else
                        Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B '**Recuadro horizontal notas**
                        especial = 0
                    End If
                End If
                
                rsnotas.Open "select cod_sec, cod_asi, num_per, cod_eva, nota from notas where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and num_per = '" & numperiodo & "' and agno = " & cmb_agno.Text & " and tipo_eva = " & tipo_EVA & " order by cod_sec, cod_asi", conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = 2580 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                                
                '                Printer.CurrentX = 100
                '''''' Campo especial
                If especial = 1 Then
                    Printer.CurrentX = 500
                Else
                    Printer.CurrentX = 100
                End If
                
                Printer.FontSize = 8
                Printer.Print (Nombreasig) ' Imprimo asignatura
                
                Printer.CurrentY = 2780 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 1000
                Printer.FontSize = 6
                'Printer.Print "APRENDIZAJE        100%" 'Imprimo asignatura
                
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                '''' modifico if
                    If val(rsnotas("nota")) <> 0 Or (val(Sector) = 11 And val(Codasi) = 6) Then
                    notas = rsnotas("nota")
                    
'''''''                    '''''' Posicion naturales
                    If (val(Sector) = 11 And val(Codasi) = 6) Then
                       posy = 5700
                       posx = 10700 + 250
                       posy = Printer.CurrentY
                    End If
                    
                    For tnotas = 1 To 24 Step 2
                    'For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                                                        
                                    If especial = 1 Then
                                            especial_prom = especial_prom + Nota
                                            especial_cont = especial_cont + 1
                                            'especial_promc = especial_promc + pro
                                    Else
                                            'Printer.Print (Nota)
                                    End If
                            
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0"))
                        End If 'sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        
                        If rsnotas("cod_asi") = 13 Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = 13 and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                'Printer.Print ("Ex.")
                            Else
                                Printer.Print (Nota)
                            End If
                        Else
                            Printer.Print (Nota)
                        End If
                                                
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                
                
                rsnotas.Open "select * from promedios where ci_alu = '" & rutalumno & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and letra_curso = '" & letra & "'and cod_sec = '" & Sector & "' and cod_asi = '" & Codasi & "' and agno = " & cmb_agno.Text & " and tipo_eva = " & tipo_EVA & " order by cod_sec, cod_asi", conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If numperiodo = 0 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    If Nota < 4# Then
                        Printer.FontBold = False
                    Else
                        Printer.FontBold = False
                    End If
                    Promsemestre = ""
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = "EX"
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    
                    If Not (rsnotas("cod_asi") = 13 Or rsnotas("cod_asi") = 22) Then
                        var_sql = "select if(count(*)>0,'SI','NO') as ex from promedios p,acta_alumexi a" _
                                & " where p.ci_alu = a.run_alu and p.cod_asi = a.cod_asi and p.ci_alu = '" & rutalumno & "'" _
                                & " and p.cod_asi = '" & rsnotas("cod_asi") & "' and a.agno = " & cmb_agno.Text _
                                & " and p.agno = a.agno and tipo_eva = " & tipo_EVA
                        objRS.Open var_sql, conn
                        exi = objRS("ex")
                        objRS.Close
                        If exi = "NO" Then
                            If val(Replace(Nota, ",", ".")) <> "0,0" Then
                                ''''' No sumar biologia quimica fisica
                                If cole = "LON001" Or cole = "SNM001" Or cole = "FLO001" Or cole = "FAR001" Then
                                    If Not ((rsnotas("cod_asi") = 3 Or rsnotas("cod_asi") = 8 Or rsnotas("cod_asi") = 7) And CodModalidad = "310" And (Ngrado = 1 Or Ngrado = 2)) Then
                                        cont = cont + 1
                                        prom = prom + val(Replace(Nota, ",", "."))
                                        Printer.Print (Nota)
                                    End If
                                Else
                                    If Not ((rsnotas("cod_asi") = 3 Or rsnotas("cod_asi") = 8 Or rsnotas("cod_asi") = 7) And CodModalidad = "310" And Ngrado = 1) Then
                                        cont = cont + 1
                                        prom = prom + val(Replace(Nota, ",", "."))
                                        Printer.Print (Nota)
                                    End If
                                End If
                                
                                If Me.opt_final_parcial(0) Then
                                         '''' Promedio especial
'''                                    If especial = 1 Then
'''                                            especial_prom = especial_prom + Nota
'''                                            'especial_promc = especial_promc + pro
'''                                    Else
   '                                         Printer.Print (Nota)
'''                                    End If
                                    
                         '           Printer.Print (Nota)
                                End If
                            End If
                        Else
                            Printer.Print ("Ex.")
                        End If
                        
                        
                    Else
                        If Me.opt_final_parcial(0) Then
                            eximi = ""
                            eximi = DevuelveCampo("acta_alumexi", "", "run_alu", "cod_asi = " & rsnotas("cod_asi") & " and run_alu ='" & rutalumno & "' and agno = " & cmb_agno.Text, conn)
                            If Len(eximi) > 5 Then
                                Printer.Print ("Ex.")
                            Else
                                If (rsnotas("cod_asi") = "13" And Promsemestre = "EX") Or Nota = "0,0" Then
                                Else
                           
                                Printer.Print (Promsemestre)
                                End If
                            End If
                        End If
                    End If
                    Printer.FontBold = False
                    
                End If
                        ''''imprime naturales
                        If posy <> 0 Then
                            '''''guardo coordenadas
                            poy = Printer.CurrentY
                            pox = Printer.CurrentX
                            Printer.CurrentY = posy
                            Printer.CurrentX = posx
                        If cole = "LON001" Or cole = "SNM001" Or cole = "FLO001" Or cole = "FAR001" Then
                            If (CodModalidad = "310" And (Ngrado = 1 Or Ngrado = 2)) And val(Codasi) = 6 And especial_prom <> 0 Then
                        
                                If Len(Mid(especial_prom / especial_cont, 1, 3)) <> 1 Then
                                    'Printer.Print (Mid(especial_prom / 3, 1, 3)) & "    " & (Mid(especial_promc / 3, 1, 3))
                                   ' c_n = (Mid(especial_prom / especial_cont, 1, 3))
                                    c_n = (Mid((especial_prom / especial_cont) + 0.04, 1, 3))
                                    sw = 1
                                    Printer.Print (c_n)
                                Else
                                    'Printer.Print (Mid(especial_prom / 3, 1, 3)) & ",0    " & (Mid(especial_promc / 3, 1, 3))
                                    'c_n = (Mid(especial_prom / especial_cont, 1, 3))
                                    c_n = (Mid((especial_prom / especial_cont) + 0.04, 1, 3))
                                    sw = 1
                                    Printer.Print (c_n & ",0")
                                End If
                                '''asigno coordenadas
                                Printer.CurrentY = poy
                                Printer.CurrentX = pox
                            End If
                        
                        Else
                            If (CodModalidad = "310" And (Ngrado = 1)) And val(Codasi) = 6 And especial_prom <> 0 Then
                        
                                If Len(Mid(especial_prom / especial_cont, 1, 3)) <> 1 Then
                                    'Printer.Print (Mid(especial_prom / 3, 1, 3)) & "    " & (Mid(especial_promc / 3, 1, 3))
                                    'c_n = (Mid(especial_prom / especial_cont, 1, 3))
                                    c_n = (Mid((especial_prom / especial_cont) + 0.04, 1, 3))
                                    sw = 1
                                    Printer.Print (c_n)
                                Else
                                    'Printer.Print (Mid(especial_prom / 3, 1, 3)) & ",0    " & (Mid(especial_promc / 3, 1, 3))
                                    'c_n = (Mid(especial_prom / especial_cont, 1, 3))
                                    c_n = (Mid((especial_prom / especial_cont) + 0.04, 1, 3))
                                    sw = 1
                                    Printer.Print (c_n & ",0")
                                End If
                                '''asigno coordenadas
                                Printer.CurrentY = poy
                                Printer.CurrentX = pox
                            End If
                        End If
                        End If

                rsnotas.Close
                RsAux.MoveNext
            Wend
                        
            Printer.Line (3650, 2700)-(3650, y1 + 500)   'linea vertical
            Printer.Line (10600, 2700)-(10600, y1 + 500) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), 2500)-(3650 + (408 * y2), y1 + 500) 'linea vertical
            Next y2
            Printer.Line (3250 + (408 * y2), y1 + 600)-(3250 + (408 * y2), y1 + 1000) 'linea vertical
            Printer.Line (10600, y1 + 600)-(10600, y1 + 1000) 'linea vertical
            
            y1 = y1 + 500
            Printer.Line (50, CLng(y1 + 100))-(11500, CLng(y1 + 500)), , B
            Printer.CurrentY = y1 + 250
            
            Printer.FontSize = 8
            Printer.CurrentX = 100
            'Printer.CurrentY = y1 + 250
            'Asistencia
            'rutalumno nombre de campo
            
            var_sql = "SELECT ci_alu,a.mes_asis,asi_r,asi_t,(100 * SUM(asi_t))/SUM(asi_r) AS porcentaje FROM asistencia a,fnza_conversion_meses c" _
                    & " WHERE a.mes_asis = c.abv_mes AND c.num_mes <= DATE_FORMAT(NOW(),'%m') AND agno = " & cmb_agno.Text & " AND ci_alu = '" & rutalumno & "'" _
                    & " GROUP BY ci_alu"
            objRS.Open var_sql, conn
            If objRS.RecordCount > 0 Then
                If objRS("porcentaje") = 100 Then
                    Printer.Print "Porcentaje de Asistencia: " & Format(objRS("porcentaje"), "0.0") & "%                                                                                                                            PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
                Else
                    Printer.Print "Porcentaje de Asistencia: " & Format(objRS("porcentaje"), "0.0") & "%                                                                                                                              PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
                End If
            Else
                Printer.Print "Porcentaje de Asistencia:                                                                                                                                      PROMEDIO FINAL DEL PERIODO" 'Imprimo asistencia
            End If
            objRS.Close
                      
            
            Printer.CurrentX = 8000
            Printer.FontSize = 8
            'Printer.Print "PROMEDIO FINAL DEL PERIODO" 'Imprimo asignatura
            Printer.CurrentY = y1 + 250
            Printer.CurrentX = 10950
            Dim NotaFinalInf As String
            If prom <> 0 And cont <> 0 Then
                '''' Promedio si es ciencias naturales
                If cole = "LON001" Or cole = "SNM001" Or cole = "FLO001" Or cole = "FAR001" Then
                    If (val(Ngrado) = 1 Or val(Ngrado) = 2) And CodModalidad = "310" And c_n <> 0 Then
                        If cole = "FLO001" Then
                            NotaFinalInf = (prom + c_n) / (cont + 1) + 0.05
                        Else
                            NotaFinalInf = Trim(str((prom + c_n) / (cont + 1)))
                        End If
                    Else
                        NotaFinalInf = Trim(str(prom / cont))
                    End If
                Else
                    If (val(Ngrado) = 1) And CodModalidad = "310" And c_n <> 0 Then
                        NotaFinalInf = Trim(str((prom + c_n) / (cont + 1)))
                    Else
                        NotaFinalInf = Trim(str(prom / cont))
                    End If
                End If
            Else
                NotaFinalInf = 0
            End If
            
            cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
            If cole = "LIN001" Then
                If prom <> 0 And cont <> 0 Then
                    NotaFinalInf = (prom / cont) + 0.05
            Else
                    NotaFinalInf = 0
            End If
            End If
            
            NotaFinalInf = Mid(NotaFinalInf, 1, 1) & "," & val(Mid(NotaFinalInf, 3, 1))
            If val(NotaFinalInf) < 4 Then
                Printer.FontBold = True
            Else
                Printer.FontBold = False
            End If
            If Me.opt_final_parcial(0) Then
                If NotaFinalInf <> "0,0" Then
                    'Printer.Print (NotaFinalInf)
                     If NotaFinalInf <> ",0" Then
                        Printer.Print (NotaFinalInf)
                     End If
                End If
            End If
            Printer.FontBold = False
    End If
    RsAux.Close
    
    
'TALLERES CURRICULARES
    var_sql = "select * from talleres where cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado & "' and tipo_tall = 1"
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
    
        y1 = y1 + 500
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 200
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print ("T A L L E R E S    C U R R I C U L A R E S")
        Printer.FontBold = False

        'rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
            ydeproceso = ydeproceso + 500
            y3 = y1 + 500
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
   
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = Y4 'donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
         
                    For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0"))
                        End If 'sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        If Nota <> "0.0" Then
                            Printer.Print (Nota) 'La notas sale sin problemas
                        End If
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                                      
                rsnotas.Open var_sql, conn
                If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If (numperiodo + 1) = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 2, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 2, 1))
                    End If
                    

                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    
                    
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                    
'                    If colegio = "FAR001" Then
'                        Printer.Print (Nota)
'                    Else
                    
                        Printer.Print (Promsemestre)
'                    End If
                    
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If
                '
                rsnotas.Close
                RsAux.MoveNext
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 500)   'linea vertical
            Printer.Line (10600, CInt(y3))-(10600, y1 + 500) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 500) 'linea vertical
            Next y2
    End If
    RsAux.Close
    
    var_sql = "select * from talleres t,alumnos_talleres at" _
            & " where at.ci_alu = '" & rutalumno & "' and t.cod_ens = at.cod_ens" _
            & " and t.cod_tall = at.cod_tall" _
            & " and t.num_gra = at.numgra and t.tipo_tall = at.tipo_tall" _
            & " and at.let_cur = '" & letra & "' and at.cod_ens = '" & CodModalidad & "'" _
            & " and at.numgra = '" & Ngrado & "' and t.tipo_tall = 2 and agno = " & cmb_agno.Text
            
    RsAux.Open var_sql, conn
    If Not RsAux.EOF Then
        y1 = y1 + 500
        Y4 = y1 + 300
        ydeproceso = Y4 - 700
        Y4 = y1 + 200
    
        Printer.FontBold = True
        Printer.FontSize = 10
        Printer.CurrentX = 100: Printer.CurrentY = (Y4 - 50): Printer.Print "T A L L E R E S    L I B R E    ELECCIÓN"
        Printer.FontBold = False

       ' rsnotas.CursorLocation = adUseClient
        Aumentosector = 0
        Totalsubsectores = 0
        prom = 0
        cont = 0
            ydeproceso = ydeproceso + 500
            y3 = y1 + 500
            While Not RsAux.EOF
                y1 = y1 + 500
                
                'ESTE ES EL PRIMER BOX DEL INFORME
                Printer.Line (50, CLng(y1))-(11500, CLng(y1 + 500)), , B
                
                tipo_tall = RsAux("tipo_tall")
                cod_tall = RsAux("cod_tall")
                Nombre_Tall = RsAux("nom_tall")
                var_sql = "select tipo_tall, cod_tall, num_per,nota" _
                        & " from notas_talleres where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and" _
                        & " num_gra = '" & Ngrado & "' and let_cur = '" & letra & "'and tipo_tall = '" & tipo_tall & "' and" _
                        & " cod_tall = '" & cod_tall & "' and num_per = '" & (numperiodo + 1) & "' and agno = " & cmb_agno.Text
                      
                rsnotas.Open var_sql, conn
                Aumentosector = Aumentosector + 500
                Printer.CurrentY = Y4 'Donde se imprime la primera asignatura
                Printer.CurrentY = Printer.CurrentY + Aumentosector
                Printer.CurrentX = 100
                Printer.FontSize = 8
                Printer.Print (Nombre_Tall) 'Imprimo asignatura
              
                aumentonota = 0
                valnota = 0
                Promproceso = 0
                Promponderado = 0
                Divisor = 0
                ydeproceso = ydeproceso + 500
                If rsnotas.RecordCount > 0 Then
                    If val(rsnotas("nota")) <> 0 Then
                    notas = rsnotas("nota")
                    
            For tnotas = 1 To Len(notas) Step 2
                        notasincoma = Mid(CStr(notas), tnotas, 2)
                        aumentonota = aumentonota + 408
                        Printer.CurrentX = 3300 ' Este valor indica en que posicion empiezan a
                        Printer.CurrentX = Printer.CurrentX + aumentonota ' imprimirse las notas
                        Printer.CurrentY = ydeproceso + 100
                        Printer.FontSize = 9
                        If Len(Trim(notasincoma)) <> 0 Then
                            Nota = Format(Int(Round((CSng(notasincoma) * 0.1) * 10, 1)) / 10, "0.0")
                            valnota = valnota + Nota
                        If Len(CStr(Nota)) = 1 Then
                            Nota = " " & Trim(Format(Nota, ".0")) 'Round(CDec(Val(Nota * 1.01)), 1) ' aqui debo dejar un numero entero 4 como 4,0
                        End If ' sin necesidad de agregarle coma como texto.
                        Divisor = Divisor + 1
                        Else
                        Nota = " "
                        End If
                        If Nota < 4# Then
                            Printer.FontBold = True
                        Else
                            Printer.FontBold = False
                        End If
                        Printer.Print (Nota)
                        Printer.FontBold = False
                    Next tnotas
                    End If
                End If
                rsnotas.Close
                var_sql = "select * from promedios_talleres" _
                        & " where ci_alu = '" & rutalumno _
                        & "' and cod_ens = '" & CodModalidad & "' and num_gra = '" & Ngrado _
                        & "' and let_cur = '" & letra & "'" _
                        & " and tipo_tall = '" & tipo_tall & "' and cod_tall = '" & cod_tall & "' and agno = " & cmb_agno.Text
                              
                rsnotas.Open var_sql, conn
            If Not rsnotas.EOF Then
                    Printer.CurrentY = ydeproceso + 100
                    Printer.CurrentX = 10950
                    If numperiodo + 1 = 1 Then
                        Nota = Mid(rsnotas("p1"), 1, 1) & "," & val(Mid(rsnotas("p1"), 3, 1))
                    Else
                        Nota = Mid(rsnotas("p2"), 1, 1) & "," & val(Mid(rsnotas("p2"), 3, 1))
                    End If
                    
                    Select Case CSng(Nota)
                            Case 0 To 0.9
                                Promsemestre = " "
                            Case 1# To 3.9
                                Promsemestre = "I"
                            Case 4# To 4.9
                                Promsemestre = "S"
                            Case 5# To 5.9
                                Promsemestre = "B"
                            Case 6# To 7#
                                Promsemestre = "MB"
                    End Select
                    If Nota < 4# Then
                        Printer.FontBold = True
                    Else
                        Printer.FontBold = False
                    End If
                    
'                    If colegio = "FAR001" Then
'                        Printer.Print (Nota)
'                    Else
                        Printer.Print (Promsemestre)
                   ' End If
                    
                    Printer.FontBold = False
                    cont = cont + 1
                    prom = prom + Nota
                End If
                rsnotas.Close
                RsAux.MoveNext
               
            Wend
                        
            Printer.Line (3650, CInt(y3))-(3650, y1 + 500) 'linea vertical
            For y2 = 1 To 17
                Printer.Line (3650 + (408 * y2), CInt(y3))-(3650 + (408 * y2), y1 + 500) 'linea vertical
            Next y2
            Printer.Line (10600, CInt(y3))-(10600, y1 + 500)
    End If
    RsAux.Close
    Imprimenotasalumnopant_tall_formativa = y1
End Function

Sub Imprimeencabezadopant_tall_formativa(tipo_EVA As Integer)
Dim colegio As String
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
Dim var_sql As String
var_sql = "select valor from cfg where param = 'codbc'"
objRS.Open var_sql, conn
colegio = objRS("valor")
objRS.Close

var_sql = "select month(now()) as mes"
objRS.Open var_sql, conn
mes = objRS("mes")
objRS.Close

Call encabezadopapel(True)
'If Me.opt_final_parcial(0) Then
'    Tipoinforme = "INFORME FINAL DE NOTAS"
'ElseIf Me.opt_final_parcial(1) Then
'    Tipoinforme = "INFORME PARCIAL DE NOTAS"
'End If

numperiodo = aperiodos(Me.lst_periodos.ListIndex)

If numperiodo = 0 Then
If mes > 6 Then
    Tipoinforme = "INFORME FINAL DE NOTAS"
Else
    Tipoinforme = "INFORME PARCIAL DE NOTAS"
End If
End If

'If numperiodo = 1 Then
'If Mes > 11 Then
'    Tipoinforme = "INFORME FINAL DE NOTAS"
'Else
If tipo_EVA = 0 Then
    Tipoinforme = "INFORME DE NOTAS SUMATIVA"
Else
    Tipoinforme = "INFORME DE NOTAS FORMATIVA"
End If
'End If
'End If

Printer.FontSize = 9
Call centrarenpapel(1000, Tipoinforme & " " & lst_periodos.Text & " " & cmb_agno.Text)    ' Este año debe ser el de proceso NO DEL SISTEMA
Printer.FontSize = 8

If colegio <> "LIN001" Then
    Printer.PaintPicture LoadPicture("\\192.168.7.101\logo\aguilita.gif"), 10000, 880
Else
    Printer.PaintPicture LoadPicture("c:\Archivos de programa\Ges_Col\objetos\insignia_lincoln.gif"), 10000, 880
End If

Printer.CurrentX = 100: Printer.CurrentY = 1400: Printer.Print ("ALUMNO"): Printer.CurrentX = 1300: Printer.CurrentY = 1400: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 1600: Printer.Print ("CURSO"): Printer.CurrentX = 1300: Printer.CurrentY = 1600: Printer.Print (":")
Printer.CurrentX = 100: Printer.CurrentY = 1800: Printer.Print ("APODERADO"): Printer.CurrentX = 1300: Printer.CurrentY = 1800: Printer.Print (":")
Printer.FontBold = False
Printer.Line (50, 2500)-(11500, 3000), , B  ' ESTE ES EL PRIMER BOX DEL INFORME
Printer.FontBold = True
Printer.FontSize = 10
Printer.CurrentX = 100: Printer.CurrentY = 2650: Printer.Print ("A S I G N A T U R A S")
Printer.FontBold = False
Printer.FontSize = 8
Aumento = 0
Printer.FontSize = 8
For t = 1 To 17
    Aumento = Aumento + 350 + 52
    Printer.CurrentX = 3400
    Printer.CurrentX = Printer.CurrentX + Aumento
    Printer.CurrentY = 2750
    Printer.Print (t)
Next t
Printer.CurrentX = 10700: Printer.CurrentY = 2550: Printer.Print ("Promedio")
Printer.CurrentX = 10690: Printer.CurrentY = 2700: Printer.Print ("Semestre")
    Printer.Line (3650, 2500)-(3650, 3100), , B         ' linea vertical
    Printer.Line (10600, 2500)-(10600, 3100), , B    ' linea vertical
End Sub

