Attribute VB_Name = "modSubs"
'------------------------------------------------------------
'Todas estas funciones estan en GesCol
'------------------------------------------------------------
' Para usar Archivos INI
Public Declare Function GetPrivateProfileSectionNames Lib "kernel32" Alias "GetPrivateProfileSectionNamesA" _
    (ByVal lpszReturnBuffer As String, ByVal nSize As Long, _
    ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" _
    (ByVal lpAppName As String, ByVal lpReturnedString As String, _
    ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
    (ByVal lpApplicationName As String, ByVal lpKeyName As Any, _
     ByVal lpDefault As String, ByVal lpReturnedString As String, _
     ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
    (ByVal lpApplicationName As String, ByVal lpKeyName As Any, _
     ByVal lpString As Any, ByVal lpFileName As String) As Long
'********** FIN INI

Public Sub IniDelete(ByVal sIniFile As String, ByVal sSection As String, _
                    Optional ByVal sKey As String = "")
    If Len(sKey) = 0 Then
        Call WritePrivateProfileString(sSection, 0&, 0&, sIniFile)
    Else
        Call WritePrivateProfileString(sSection, sKey, 0&, sIniFile)
    End If
End Sub

Public Sub IniWritte(ByVal lpFileName As String, ByVal lpAppName As String, _
                    ByVal lpKeyName As String, ByVal lpString As String)
    Call WritePrivateProfileString(lpAppName, lpKeyName, lpString, lpFileName)
End Sub

Public Function IniGets(ByVal lpFileName As String, ByVal lpAppName As String, _
                       ByVal lpKeyName As String, _
                       Optional ByVal lpDefault As String = "") As String
    Dim LTmp As Long
    Dim sRetVal As String
    sRetVal = String$(255, 0)
    LTmp = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, sRetVal, Len(sRetVal), lpFileName)
    If LTmp = 0 Then
        IniGets = lpDefault
    Else
        IniGets = Left(sRetVal, LTmp)
    End If
End Function


Public Function IniGetSection(ByVal lpFileName As String, _
                              ByVal lpAppName As String) As Variant
    Dim tContenidos As Collection
    Dim nSize As Long
    Dim i As Long
    Dim j As Long
    Dim sTmp As String
    Dim sClave As String
    Dim sValor As String
    sBuffer = String$(32767, Chr$(0))
   
    nSize = GetPrivateProfileSection(lpAppName, sBuffer, Len(sBuffer), lpFileName)
    If nSize Then
        Set tContenidos = New Collection
        sBuffer = Left$(sBuffer, nSize)
        i = InStr(sBuffer, vbNullChar & vbNullChar)
        If i Then
            sBuffer = Left$(sBuffer, i - 1)
        End If
        Do
            i = InStr(sBuffer, Chr$(0))
            If i Then
                sTmp = LTrim$(Left$(sBuffer, i - 1))
                If Len(sTmp) Then
                    j = InStr(sTmp, "=")
                    If j Then
                        sClave = Left$(sTmp, j - 1)
                        sValor = LTrim$(Mid$(sTmp, j + 1))
                        tContenidos.Add sClave
                        tContenidos.Add sValor
                    End If
                End If
                sBuffer = Mid$(sBuffer, i + 1)
            End If
        Loop While i
        If Len(sBuffer) Then
            j = InStr(sBuffer, "=")
            If j Then
                sClave = Left$(sBuffer, j - 1)
                sValor = LTrim$(Mid$(sBuffer, j + 1))
                tContenidos.Add sClave
                tContenidos.Add sValor
            End If
        End If
    End If
    Set IniGetSection = tContenidos
End Function


Public Function IniGetSections(ByVal lpFileName As String) As Variant
    ' Devuelve todas las secciones de un fichero INI
    Dim tContenidos As Collection
    Dim nSize As Long
    Dim i As Long
    Dim sTmp As String
    sBuffer = String$(32767, Chr$(0))
    nSize = GetPrivateProfileSectionNames(sBuffer, Len(sBuffer), lpFileName)
       
    If nSize Then
        Set tContenidos = New Collection
        sBuffer = Left$(sBuffer, nSize)
        i = InStr(sBuffer, vbNullChar & vbNullChar)
        If i Then
            sBuffer = Left$(sBuffer, i - 1)
        End If
        Do
            i = InStr(sBuffer, Chr$(0))
            If i Then
                sTmp = LTrim$(Left$(sBuffer, i - 1))
                If Len(sTmp) Then
                    tContenidos.Add sTmp
                End If
                sBuffer = Mid$(sBuffer, i + 1)
            End If
        Loop While i
        If Len(sBuffer) Then
            tContenidos.Add sBuffer
        End If
    End If
    Set IniGetSections = tContenidos
End Function


Function AcercaDe(strPrograma As String, strVersion As String, strTitle As String)
    frmAbout.Caption = "Acerca de " & strPrograma
    frmAbout.lblVersion.Caption = "Versión " & strVersion
    frmAbout.lblTitle.Caption = strTitle
    frmAbout.Show vbModal
End Function

Public Sub IniciaIngreso(frmIniciar As Form, agno As String)
    Dim i As Integer
    frmIniciar.cmbListaMeses = ""
    frmIniciar.cmbModalidad.Text = ""
    frmIniciar.cmbListaNiveles.Text = ""
    frmIniciar.cmbListaLetras.Text = ""
    frmIniciar.optFormaGrilla.Item(0).Value = True
    CargaMesesCombo frmIniciar.cmbListaMeses, agno
    frmIniciar.gridCalend.FixedCols = 1
    frmIniciar.gridCalend.FixedRows = 1
    frmIniciar.gridCalend.Clear
    frmIniciar.gridCalend.Cols = 7
    frmIniciar.gridCalend.Rows = 7
    frmIniciar.gridCalend.FormatString = "|^Lun|^Mar|^Mie|^Jue|^Vie|^Sab|^Dom" ';|1|2|3|4|5|6"
    frmIniciar.gridCalend.ColWidth(0) = 100
    For i = 1 To 7
        frmIniciar.gridCalend.ColWidth(i) = 370
    Next

End Sub


