slette en linie fra tekstfil
Hej eksperter.Jeg er ved at lave et lille prg., som læser tekst fra en textfil ind i comboboxe. Det virker fint og jeg kan også tilføje nye linier. Men jeg kan ikke finde ud af og slette en linie igen. Det drejer sig ca. om 60 linier. Og vil helst bruge en textfil, da der ikke skal være søgninger, rapporter...
Måske skal det laves på en anden måde ?
vh thjoe
Jeg har hentet og viderebrugt denne kode:
Option Explicit
Dim sPath As String
Dim vData As Variant
Private Sub CmdSave_Click()
Open sPath For Append As #20
Print #20, Text1.Text & Chr(44) & Text2.Text & Chr(44), Text3.Text
Close #20
MsgBox sPath
End Sub
Private Sub LoadText(Index As Integer)
Dim vTemp As Variant
vTemp = Split(vData(Index), ",")
Text1.Text = vTemp(0)
Text2.Text = vTemp(1)
Text3.Text = vTemp(2)
End Sub
Private Sub Combo1_Click()
LoadText (Combo1.ListIndex)
End Sub
Private Sub Combo2_Click()
LoadText (Combo2.ListIndex)
End Sub
Private Sub Combo3_Click()
LoadText (Combo3.ListIndex)
End Sub
Private Sub Command2_Click()
Dim sTemp As String, sContent As String
sTemp = App.Path & "\Personen2.txt"
Open App.Path & "\Personen2.txt" For Input As 1
sContent = String(LOF(1), "*")
' MsgBox Len(sContent)
sContent = Input(LOF(1), #1)
MsgBox sContent
Close
End Sub
Private Sub Form_Load()
Dim iFile As Integer
Dim sText As String
Dim vTemp As Variant
Dim iCount As Integer
' Assign a value to the Form string variable sPath
sPath = App.Path & "\Personen2.txt"
iFile = FreeFile
Open sPath For Input As iFile
' Read the content of the file as a whole
sText = Input(LOF(iFile), #iFile)
' Load the content of the file into array vData
vData = Split(sText, vbNewLine)
Close ' close all open files
For iCount = 0 To UBound(vData) - 1
' Load the current element of array vData into array vTemp
vTemp = Split(vData(iCount), ",")
' Load the elements of array vTemp into Combo Boxes
Combo1.AddItem vTemp(0)
Combo2.AddItem vTemp(1)
Combo3.AddItem vTemp(2)
Next iCount
End Sub
