hallo,
ich speichere beim Beenden der Form die Inhalte einiger Controls
das Speichern klappt INI sieht korrekt aus
Die API laß ich mal weg
Public MyIniFile as String MyIniFile = App.Path & "\Controls.ini" Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
SaveCtrlsTemp Me, "Controls" ' Control-Inhalt speichern
End Sub aber beim einlesen tut sich garnix Private Sub cmdLetzteDaten_Click()
' Control-Inhalte wiederherstellen
RestoreCtrlsTemp Me, "Controls" ' Control-Inhalt speichern
End Sub ' Inhalte der Controls speichern
Public Sub SaveCtrlsTemp(ByVal Form As Form, _
ByVal IniSection As String)
Dim Ctl As Control
Dim x As String
Dim value As String
' Alle Controls der übergebenen Form durchlaufen
For Each Ctl In Form.Controls
With Ctl
x = .Name
' Prüfen, ob Steuerelementfeld (Array)
On Local Error Resume Next
x = x & "(" & CStr(.index) & ")"
On Local Error GoTo 0
End With
value = vbNullString
'-----------------------------------------------------------------------
If TypeOf Ctl Is sevOption Or _
TypeOf Ctl Is sevCheck Then 'sevOption/sevCheck
value = CStr(Ctl.value)
'-----------------------------------------------------------------------
ElseIf TypeOf Ctl Is sevText Then 'sevText
value = Ctl.Text
'-----------------------------------------------------------------------
Else
End If
' Inhalt/Wert speichern
If value <> vbNullString Then
WritePrivateProfileString IniSection, x, value, MyIniFile
End If
Next
End Sub
Public Sub RestoreCtrlsTemp(ByVal Form As Form, _
ByVal IniSection As String) ' Inhalte der Controls lesen
Dim Ctl As Control
Dim x As String
Dim value As String
Dim lRet As Long
' Alle Controls der übergebenen Form durchlaufen
For Each Ctl In Form.Controls
With Ctl
x = .Name
' Prüfen, ob Steuerelementfeld (Array)
On Local Error Resume Next
x = x & "(" & CStr(.index) & ")"
On Local Error GoTo 0
End With
value = Space$(256)
lRet = GetPrivateProfileString(IniSection, x, vbNullString, _
value, Len(value), MyIniFile)
If lRet <> 0 Then
value = Left$(value, lRet)
'------------------------------------------------------------------------
If TypeOf Ctl Is sevOption Then 'sevOption
Ctl.value = CBool(value)
'------------------------------------------------------------------------
ElseIf TypeOf Ctl Is sevText Then 'sevText
Ctl.Text = value
'------------------------------------------------------------------------
ElseIf TypeOf Ctl Is sevCheck Then 'sevCheck
Ctl.value = CInt(value)
'------------------------------------------------------------------------
Else
End If
End If
Next
End Sub ich finde da irgendwie keinen Fehler !!
wer kann mir da bitte helfen?
gruß Sanny |