01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 |
|
Private Declare PtrSafe Function GetPrivateProfileStringA Lib "kernel32" ( _
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
Private Declare PtrSafe Function WritePrivateProfileStringA Lib "kernel32" ( _
ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, _
ByVal lpFileName As String) As Long
Function SetGetInidaten(sBereich As String, sItem As String, Optional sDaten As String) As String
' Schreibt Daten in die Textdatei oder liest Daten aus der Textdatei
Dim sPfad As String, sTxt As String * 5000, l As Integer
sPfad = Environ$("TEMP") & "\MeineUserforms.txt"
Debug.Print Dir(sPfad)
If sDaten <> "" Then
WritePrivateProfileStringA sBereich, sItem, sDaten, sPfad
Else
l = GetPrivateProfileStringA(sBereich, sItem, "", sTxt, 5000, sPfad)
SetGetInidaten = Left$(sTxt, l)
End If
End Function
Sub Schreibewas1()
SetGetInidaten "Userform1", "Textbox1", UserForm1.TextBox1.Value
SetGetInidaten "Userform1", "Textbox2", UserForm1.TextBox2.Value
End Sub
Sub Lesewas1()
UserForm1.TextBox1.Value = SetGetInidaten("Userform1", "Textbox1")
UserForm1.TextBox2.Value = SetGetInidaten("Userform1", "Textbox2")
UserForm1.Show
End Sub
' ###################### In der Registry speichern ###################################
Sub Schreibewas2()
SaveSetting "MeineUserforms", "Userform1", "Textbox1", UserForm1.TextBox1.Value
SaveSetting "MeineUserforms", "Userform1", "Textbox1", UserForm1.TextBox1.Value
End Sub
Sub Lesewas2()
UserForm1.TextBox1.Value = GetSetting("MeineUserforms", "Userform1", "Textbox1", "")
UserForm1.TextBox1.Value = GetSetting("MeineUserforms", "Userform1", "Textbox1", "")
End Sub
|