könntet ihr mir bitte folgenden Code für Excel ändern? Ich schaffe es einfach nicht. :-(
Private INIIntern As String
Private Sub UserForm_Activate()
INIIntern = "C:\Dok1.ini"
For Each x In Me.Controls 'Alle Schaltflächen auf der UserForm schleifen
If TypeOf x Is MSForms.OptionButton Or _
TypeOf x Is MSForms.CheckBox Or _
TypeOf x Is MSForms.TextBox Then
tmp = ZUE(0, System.PrivateProfileString(FileName:=INIIntern, _
Section:=Me.Name, Key:=x.Name))
If TypeOf x Is MSForms.TextBox Then 'Klartext
x.Text = tmp
Else
If IsNumeric(tmp) Then x.Value = Int(tmp) 'Boolean
End If
End If
Next
End Sub
Private Sub UserForm_Terminate()
For Each x In Me.Controls
If TypeOf x Is MSForms.OptionButton Or _
TypeOf x Is MSForms.CheckBox Or _
TypeOf x Is MSForms.TextBox Then
If TypeOf x Is MSForms.TextBox Then
tmp = ZUE(1, x.Text) 'Klartext
Else
tmp = Int(x.Value) 'Boolean
End If
System.PrivateProfileString(FileName:=INIIntern, _
Section:=Me.Name, Key:=x.Name) = tmp
End If
Next
End Sub
Private Function ZUE(Richtung As Long, strT As String) As String
'Konvertiert Zeilenumbrüche in X'FF' und umgekehrt
If Richtung = 0 Then 'X'FF' nach Zeilenschaltung
ofs = InStr(strT, Chr(255))
While ofs > 0
strT = Left(strT, ofs - 1) & vbCrLf & Right(strT, Len(strT) - ofs)
ofs = InStr(strT, Chr(255))
Wend
Else 'Zeilenschaltung nach X'FF'
ofs = InStr(strT, Chr(13))
While ofs > 0
strT = Left(strT, ofs - 1) & Chr(255) & Right(strT, Len(strT) - ofs - 1)
ofs = InStr(strT, Chr(13))
Wend
End If
ZUE = strT
End Function
Danke für eure Hilfe.
Und tschüß
andreas