patriciaxxx
Programmer
I have a text file which will contain at any one time, one string off varying length in the following style:
D0 CF 11 E0 A1 B1 1A E1 00 00 00 00 00 00 00
Basically always groups of any 2 characters separated by a space, and always one row no matter how long the string was.
I need to separate the string into substrings (separate rows) of a length I choose and in the following style.
"D0 CF 11 E0 " & _
"A1 B1 1A E1 " & _
"00 00 00 00 " & _
"00 00 00 "
The above example would be the desired result if I had chose a string length of 4.
The below example would be the result if I had selected a string length of 7.
"D0 CF 11 E0 A1 B1 1A" & _
"E1 00 00 00 00 00 00" & _
"00"
Then write the results to a new text file.
This is my code so far, it reads the file but that’s it. I have tried using the split function but couldn’t get it to do what I needed.
Code:
Sub ReadLines()
Dim sInput As String
Dim i As Long
Open "C:\test.txt" For Input As #1
Do While Not EOF(1)
Input #1, sInput
Debug.Print sInput
Loop
End Sub
Any help would be much appreciated.