I am using freefile and I have read the four first lines of data in my .txt and then made it stop.Now if I press Cammand1_Click() again I want it to read the next four lines.
Could anyone help?
Thanks
Coco
Printable View
I am using freefile and I have read the four first lines of data in my .txt and then made it stop.Now if I press Cammand1_Click() again I want it to read the next four lines.
Could anyone help?
Thanks
Coco
Hi Coco,
Here's how to do it.
Create a VB project with a big Textbox and a Command Button. For the Textbox, set the Multiline property to True and give it a Vertical Scroll Bar.
Put this code in the VB Editor:
Change "c:\bootlog2.txt" to indicate the path and name of your file.
All the best.Code:Option Explicit
Private Sub Command1_Click()
Dim lFileNum As Long
Dim stTemp() As String
Static iCounter As Integer
Dim iFourlines As Integer
Dim iLoop As Integer
Dim stHold As String
Dim iPreviousCount As Integer
lFileNum = FreeFile
Open "c:\bootlog2.txt" For Input As lFileNum
Do Until iPreviousCount = iCounter
Line Input #lFileNum, stHold
iPreviousCount = iPreviousCount + 1
Loop
Do Until iFourlines = 4 Or EOF(lFileNum)
ReDim Preserve stTemp(iFourlines)
Line Input #lFileNum, stTemp(iFourlines)
iCounter = iCounter + 1
iFourlines = iFourlines + 1
Loop
For iLoop = 0 To (iFourlines - 1)
Text1 = Text1 & stTemp(iLoop) & vbCrLf
Next
Text1.SelStart = Len(Text1)
Text1.SetFocus
Close lFileNum
End Sub
Private Sub Form_Load()
Text1 = ""
End Sub
------------------
OneSource
.Quote:
The truth may be out there, but it's in here too!
[This message has been edited by OneSource (edited 02-09-2000).]