- 'Placez ceci dans un module
-
- Function Chargement(Fichier As String)
-
- Dim Section, Valeur As String
- Open Fichier For Input As #1
- Do While Not EOF(1)
- Line Input #1, Data$ 'Ligne du fichier texte
- Section = LCase(Split2(Data$, ":", 1))
- Valeur = LCase(Split2(Data$, ":", 2))
-
- 'Ignore les commentaire et ligne vide
- If Left(Data$, 1) = "#" Or Left(Data$, 1) = "" Then
-
- 'Lit les paramètres
- ElseIf Section = "port" Then MsgBox "Port d'écoute: " & Valeur
- ElseIf Section = "texte" Then MsgBox "Texte: " & Valeur
- 'Paramètre inconnu
- Else
- MsgBox "Paramètre inconnu: " & Section
- End If
-
- Loop
- Close #1
-
- End Function
-
- Function Split2(Texte, Delimiteur, Num)
-
- On Error Resume Next
- 'Crée un tableau ou sera placé les paramètres
- Num = Int(Num)
- Dim Str1() As String
- Str1() = Split(Texte, Delimiteur)
- For i = 0 To UBound(Str1)
- Split2 = Str1(Num - 1)
- Next i
-
- End Function
'Placez ceci dans un module
Function Chargement(Fichier As String)
Dim Section, Valeur As String
Open Fichier For Input As #1
Do While Not EOF(1)
Line Input #1, Data$ 'Ligne du fichier texte
Section = LCase(Split2(Data$, ":", 1))
Valeur = LCase(Split2(Data$, ":", 2))
'Ignore les commentaire et ligne vide
If Left(Data$, 1) = "#" Or Left(Data$, 1) = "" Then
'Lit les paramètres
ElseIf Section = "port" Then MsgBox "Port d'écoute: " & Valeur
ElseIf Section = "texte" Then MsgBox "Texte: " & Valeur
'Paramètre inconnu
Else
MsgBox "Paramètre inconnu: " & Section
End If
Loop
Close #1
End Function
Function Split2(Texte, Delimiteur, Num)
On Error Resume Next
'Crée un tableau ou sera placé les paramètres
Num = Int(Num)
Dim Str1() As String
Str1() = Split(Texte, Delimiteur)
For i = 0 To UBound(Str1)
Split2 = Str1(Num - 1)
Next i
End Function