|
-
Dec 7th, 2006, 04:15 PM
#1
Thread Starter
Lively Member
looping through text file
Hey everyone
I've been using this code for awhile now and I'm trying to mod it. I'm having no luck thus far.
I want to remove the empty space between the "N" and the number that follows it.
Any help would be nice
%
O0000
(PROGRAM NAME - U-CUT2 )
(DATE=DD-MM-YY - 19-06-06 TIME=HH:MM - 12:40 )
N 100 G20
N 102 G0 G17 G40 G49 G80 G90
N 104 G91 G28 Z0.
N 106 G91 G28 X0. Y0.
N 108 G92 X0. ? Y0. ? Z0. ?
N 110 G0 G90 G52 X2.847 Y0. S2000 M3
N 112 Z.25
N 113 G04 P1
N 114 Z.1
N 115 G04 P1
N 116 G1 Z0. F10.
N 118 X2.848
N 119 G04 P1
N 120 X2.849
N 121 G04 P1
N 122 X2.85
N 123 G04 P1
N 124 X2.851
N 125 G04 P1
VB Code ________________________________
Private Sub Command1_Click()
Dim sContent As String
Dim iInputFile As Integer
Dim iOutputFile As Integer
Dim iFirstSpace As Integer
Dim iLineNumber As Integer
iInputFile = FreeFile()
Open "C:\Ni\Nc\Nc.T" For Input As #iInputFile
iOutputFile = FreeFile()
Open "C:\Ni\Nc\Nc2.T" For Output As #iOutputFile
Do While Not EOF(iInputFile)
Line Input #iInputFile, sContent
Print #iOutputFile, sContent
iFirstSpace = InStr(sContent, " ") ' Find the position of the first space
If Mid$(sContent, iFirstSpace, 1) = " " Then ' Check the first character after the first space
'iLineNumber = CInt(Mid$(sContent, 2, iFirstSpace - 2)) + 1 ' Get the line number, then add 1
Print #iOutputFile, "" '& iLineNumber & "" ' Create and print the new line
End If
Loop
Close #iInputFile
Close #iOutputFile
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|