ich möchte in einer Textdatei nach einem Zeichen suchen(#). Dann möchte ich die Fundstelle (mit 3 Zeichen dahinter) in einem Array speichern!?
Wie ist das möglich?
Danke für jede Hilfe.
Gruß Andi
Sub SearchandSave()
Dim arr() As String, i&, sSource$
Dim sText$, j&
sSource = ThisWorkbook.path & "/" & "Test.txt"
Open sSource For Input As #1
While Not EOF(1)
Line Input #1, sText
If InStr(1, sText, "#", vbTextCompare) > 0 Then
i = i + 1
ReDim Preserve arr(1 To i)
arr(i) = sText
End If
Wend
Close 1
For j = 1 To UBound(arr)
Debug.Print arr(j)
Next j
End Sub
Sub SearchandSave()
Dim arr() As String, i&, sSource$
Dim sText$, j&
sSource = ThisWorkbook.path & "\Test.txt"
Open sSource For Input As #1
While Not EOF(1)
Line Input #1, sText
If InStr(1, sText, "#", vbTextCompare) > 0 Then
i = i + 1
ReDim Preserve arr(1 To i)
arr(i) = sText
End If
Wend
Close 1
For j = 1 To UBound(arr)
Debug.Print arr(j)
Next j
End Sub
Sub SearchandSave()
Dim arr() As String, i&, sSource$
Dim sText$, j&
sSource = ThisWorkbook.Path & "\Test.txt"
Open sSource For Input As #1
While Not EOF(1)
Line Input #1, sText
Do Until InStr(1, sText, "#", vbTextCompare) = 0
i = i + 1
ReDim Preserve arr(1 To i)
arr(i) = Mid(sText, InStr(1, sText, "#", vbTextCompare), 4)
sText = Mid(sText, InStr(1, sText, "#", vbTextCompare) + 3, Len(sText))
Loop
Wend
Close 1
For j = 1 To UBound(arr)
Debug.Print arr(j)
Next j
End Sub