Hallo und einen schönen Samstag,
ich habe mal wieder so ein blödes Problem und komme einfach nicht weiter.
Also ich habe ein Picturebox-Array pic(0) bis pic(6).
Nun erzeuge ich ein Richtextbox-Array.
Die Richtextboxen möchte ich nun laden,löschen,speichern.
Hier mein Code:
Private Sub Command1_Click()
Dim myPropBag As New PropertyBag
Dim i
Dim F
With myPropBag
On Error Resume Next
.WriteProperty "anzahl", Label2.Caption, ""
For i = 1 To RTB1.Count - 1
'Label1.Caption = i
.WriteProperty "width", RTB1(i).Width, 0
.WriteProperty "top", RTB1(i).Top, 0
.WriteProperty "left", RTB1(i).Left, 0
.WriteProperty "text", RTB1(i).TextRTF, ""
Next i
End With
If Dir$(App.Path & "\user.dat", vbNormal) <> "" Then Kill App.Path & "\user.dat"
F = FreeFile
Open App.Path & "\user.dat" For Binary As #F
Put #F, , myPropBag.Contents
Close #F
End Sub
Private Sub Command2_Click()
Dim myPropBag As New PropertyBag
Dim F
Dim vInhalt As Variant
Dim i
If Dir$(App.Path & "\user.dat", vbNormal) <> "" Then
F = FreeFile
Open App.Path & "\user.dat" For Binary As #F
Get #F, , vInhalt
Close #F
myPropBag.Contents = vInhalt
With myPropBag
On Error Resume Next
Label2.Caption = .ReadProperty("anzahl", "")
For i = 1 To RTB1.Count - 1
Load RTB1(i)
RTB1(i).Width = .ReadProperty("width", 0)
RTB1(i).Top = .ReadProperty("top", 0)
RTB1(i).Left = .ReadProperty("left", 0)
RTB1(i).TextRTF = .ReadProperty("text", "")
RTB1(i).Visible = True
RTB1(i).ZOrder 0
Next i
End With
End If
End Sub
Private Sub pic_DblClick(Index As Integer)
Dim i
On Error Resume Next
Load RTB1(pic(Index).Index)
RTB1(pic(Index).Index).Left = pic(Index).Left + 90
RTB1(pic(Index).Index).Top = pic(Index).Top + 100
RTB1(pic(Index).Index).Visible = True
RTB1(pic(Index).Index).ZOrder 0
Label1.Caption = Index
For i = 1 To RTB1.Count - 1
Label2.Caption = Index
Next i
End Sub
Private Sub RTB1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete And Shift = 1 Then
Dim i, j As Integer
On Error Resume Next
Unload RTB1(pic(Index).Index)
End If
End Sub Das Problem ist das wenn ich die gespeicherte Datei aufrufe die Richtextbox-Index sich veränder.
Ist mir schon klar. Ich möchte aber das Richtextbox-Index gleich der Picturebox-index ist.
Bekomme ich aber nicht hin.
Vielleicht kann mir da Jemand helfen.
Vielen dank und Gruß |