Für alle nochmal, das was CyberDreams mir geschrieben hat (@ CyberDreams danke noch mal):
In ein Modul, folgendes:
Option Explicit
'----------------------------------------------------------------------------
' API
'----------------------------------------------------------------------------
Private 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
Private 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
'----------------------------------------------------------------------------
' WriteINI
'----------------------------------------------------------------------------
Public Sub WriteINI(ByVal sSection As String, ByVal sEntry As String, ByVal _
sValue As String, ByVal sFile As String)
Call WritePrivateProfileString(sSection, sEntry, ToStr(sValue), sFile)
End Sub
'----------------------------------------------------------------------------
' ReadINI
'----------------------------------------------------------------------------
Public Function ReadINI(ByVal sSection As String, ByVal sEntry As String, ByVal _
sFile As String) As String
Dim lValue As Long
Dim sRet As String
sRet = String(8192, 0)
lValue = GetPrivateProfileString(sSection, sEntry, "", sRet, 8192, sFile)
ReadINI = Left$(sRet, lValue)
End Function
'----------------------------------------------------------------------------
' ToStr
'----------------------------------------------------------------------------
Private Function ToStr(ByVal vValue As Variant) As String
On Error Resume Next
ToStr = CStr(vValue)
End Function In eine Form (frmMain) mit 2 TextBoxen (txtName(0) und txtName(1)) und wobei die einträge in eine ListBox geladen werden sollten:
Option Explicit
Private Sub cmdSpeichern_Click()
Dim i As Integer
For i = 0 To txtName.Count - 1
Call WriteINI("frmMain" & i, "Name", txtName(i), App.Path & _
"\Bin\Daten.ini")
List1.AddItem txtName(i).Text
Next i
End Sub Das war's auch schon |