salut à tous et une bonne année,

dans les tutoriels j'ai trouvé du code pour lire dans fichier .ini

j'ai essayé mais cà n'a pas marché.
au fait je teste pour pouvoir le développer.

voici ce que j'ai fait:

dans un module j'ai mis:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Private Declare Function GetPrivateProfileString Lib "kernel32" _
    Alias "GetPrivateProfileStringA" _
    (ByVal Section As String, ByVal Cle As Any, ByVal ValeurParDefaut As String, _
    ByVal lpReturnedString As String, ByVal nSize As Long, ByVal Fichier As String) As String
 
Private Function LitDansFichierIni(Section As String, Cle As String, Fichier As String, _
    Optional ValeurParDefaut As String = "") As String
 
Dim strReturn As String
'strReturn = String(255, 0)
strReturn = GetPrivateProfileString(Section, Cle, ValeurParDefaut, , , Fichier)
'LitDansFichierIni = Left(strReturn, InStr(strReturn, Chr(0)) - 1)
 
End Function
et ceci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Private Sub Command1_Click()
Text1.Text = LitDansFichierIni("NMT30", "mouv", "C:\Documents and Settings\lma\Desktop\liste_route.ini")
End Sub
et j'ai comme message
Run-time error '13' type mismatch
et la ligne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
Text1.Text = LitDansFichierIni("NMT30", "mouv", "C:\Documents and Settings\lma\Desktop\liste_route.ini")
est sélectionnée

quelqu'un peut me corriger?
merci