1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
| 'Définition des variables publiques
'**********************************
Public frmStatutCompil As frmListe
'Définition des variables locales
'********************************
Private mTableConvert() As Integer
'***********************************************************************************
'Méthodes publiques
'***********************************************************************************
Public Function CreatePass() As Boolean
Const Nb_Rubrique = 30
Dim Cpte As Integer
Dim mGestFichier As File
Dim mGestFichiers As New FileSystemObject
Dim PosRub(Nb_Rubrique - 1) As Variant
CreatePass = False
'Si le fichier compilé existe déjà, on l'efface
'**********************************************
On Error GoTo CompileErreur
If mGestFichiers.FileExists(App.Path + FichierBDD_Projet_pass) Then
mGestFichiers.DeleteFile App.Path + FichierBDD_Projet_pass, True
End If
Screen.MousePointer = vbHourglass
'Création et ouverture du fichier compilé
'****************************************
Open App.Path + FichierBDD_Projet_pass For Binary As #1
Set frmStatutCompil = New frmListe
frmStatutCompil.Show , fMainForm
DoEvents
'Compile les utilisateurs
'************************
PosRub(1) = CompileUtil
Close #1
Screen.MousePointer = vbNormal
frmStatutCompil.Fin IDCompilOK
CreatePass = True
Exit Function
CompileErreur:
Dim Description As String
Description = Err.Description
Close #1
frmStatutCompil.Fin IDCompilNOK, True
Screen.MousePointer = vbNormal
MsgBox Description, vbCritical, LoadRessourceString(IDTitre)
End Function
'***********************************************************************************
'Méthodes privée
'***********************************************************************************
Private Function EcritByte(ByVal Valeur As Long, _
Optional Position As Long = 0) As Long
'Ecrit un octet à une position donnée ou à la position courante
'**************************************************************
If Position Then
Put #1, Position, CByte(Valeur Mod 256)
Else
Put #1, , CByte(Valeur Mod 256)
End If
EcritByte = PositionCourante
End Function
*****************************
Private Function PositionCourante() As Long
'Renvoi la position courante dans le fichier - 1 (on démarre à 0 au lieu de 1)
'*****************************************************************************
PositionCourante = Seek(1)
End Function
Private Sub CompileTexte(ByVal Texte As String, Optional NomFichier As Boolean = False)
Dim Cpte As Integer
For Cpte = 1 To Len(Texte)
'Compile un caractère de la chaine de texte
'******************************************
If Not NomFichier Then
EcritByte Asc(Mid(Texte, Cpte, 1))
End If
Next Cpte
End Sub
Private Function CompileUtil() As Long
Dim mListeCodes As New clsListeObjet
Dim mTamponCodes() As Variant
Dim Cpte As Integer
Dim Count As Integer
'Création de la liste des Codes
'******************************
mListeCodes.Populate mUTIL
Count = mListeCodes.Count
'Création d'une table de vecteurs dont le premier
'élément est le nombre de codes
'************************************************
ReDim mTamponCodes(Count) As Variant
mTamponCodes(0) = Count
frmStatutCompil.InitRubrique IDCode, Count
'Les éléments suivants sont les vecteurs vers les Codes compilés
'***************************************************************
For Cpte = 1 To mListeCodes.Count
frmStatutCompil.MAJRubrique Cpte
mTamponCodes(Cpte) = CompileUnUtil(mListeCodes.Item(Cpte))
Next Cpte
frmStatutCompil.MAJRubrique Count, "OK"
End Function
Private Function CompileUnUtil(Code As clsUtil) As Long
Dim Cpte As Integer
Dim mElément As clsEléments
'Renvoi l'adresse de début de compilation du code
'************************************************
CompileUnUtil = 1
With Code
CompileTexte .Nom + "|"
CompileTexte .MotPasse + "|"
CompileTexte (.Groupe / 2)
End With
End Function |
Partager