Q: Manipulating printing
I'm trying to print a file of 50 numbers to print out skipping every 5th
number. This is the code I've tried:
start = 1
endline = 4
Open "a1.csv" For Input As #1
For i = 1 To 10
For j = start To endline
Line Input #1, info
Print #2, info
Print i, j, info
Next j
start = start + 5
endline = endline + 5
Next i
Close #1
The counters i & j print out correctly. There are 10 groups of i, with
4 1's, 4 2's, etc. The j counter goes 1,2,3,4,6,7,8,9,11,12,13,14,etc.
but the input file prints in order from 1 to 40. I want it to be same as j
counter. Any ideas?
Dave Paton; penserv@therockies.com
A
'make a new project; a form and two commandbuttons
'place the ascii-file NUMBERS.TXT in the same directory
'dont forget to make the file with some numbers in it!!
'insert the code on the proper places
'press F5
Option Explicit
Dim intX As Integer
Dim intFileNumber As Integer
Dim bSkip As Byte
Dim strDummy As String
Private Sub Command1_Click()
'get & open file
bSkip = 0
intFileNumber = FreeFile
Open App.Path & "\numbers.txt" For Input As #intFileNumber
Do While Not EOF(intFileNumber)
'print but skip every 5th input
bSkip = bSkip + 1
Line Input #intFileNumber, strDummy
If bSkip = 5 Then
Printer.Print
bSkip = 0
Else
Printer.Print CStr(bSkip) & " --> " & strDummy
End If
Loop
Close #intFileNumber
Printer.EndDoc
End Sub
Private Sub Command2_Click()
Dim answer
answer = InputBox("How many times do you want to print?", , 2)
If answer = "" Then Exit Sub
'get & open file
bSkip = 0
intFileNumber = FreeFile
Open App.Path & "\numbers.txt" For Input As #intFileNumber
Do While Not EOF(intFileNumber)
bSkip = bSkip + 1
Line Input #intFileNumber, strDummy
'print but skip every 5th input
If bSkip = 5 Then
Printer.Print
bSkip = 0
Else
'print the number multiple times
For intX = 0 To CInt(answer)
Printer.Print CStr(bSkip) & " --> " & strDummy
Next intX
End If
Loop
Close #intFileNumber
Printer.EndDoc
End Sub
Return