Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# text files

Posted on 2003-03-23
Medium Priority
137 Views
In the following code I need to: if line 10,21,32... = n then take the 9 lines above and the 10 line and put them in a buffer and if the 10,21,32... lines  are not n move on without storing the info in the buffer here is the code I have:

if Dir\$("C:\PilotInfo\boards.txt") <> "" Then
frmVeiwInfo.Show
frmVeiwInfo.Caption = "not back"
Wrap\$ = Chr\$(13) & Chr\$(10)
Open "C:\PilotInfo\boards.txt" For Input As #1
While Not EOF(1)
Line Input #1, buf
linenum = linenum + 1
For i = 10 To linenum Step 11
If buf = "n" Or buf = "N" Then

End If
Next
frmVeiwInfo.Text1.Text = frmVeiwInfo.Text1.Text + buf
Wend

Close #1

Else
Prompt = "C:\PilotInfo\quotes.txt does not exist"
MsgBox (Prompt), , "Error"
End If
0
Question by:mboscorellio

LVL 2

Accepted Solution

JoaTex earned 200 total points
ID: 8190191
Hi

Here is Your code to do That.

Option Explicit
Dim LineNum
Dim MemoLine
Dim Wrap\$
Dim Buf
Dim prompt
Private Sub Form_Click()
LineNum = 0
MemoLine = 10
frmVeiwInfo.Text1.Text = ""
If Dir\$("C:\PilotInfo\boards.txt") <> "" Then
frmVeiwInfo.Show
frmVeiwInfo.Caption = "not back"
Wrap\$ = Chr\$(13) & Chr\$(10)
Open "C:\PilotInfo\boards.txt" For Input As #1
While Not EOF(1)
Line Input #1, Buf
frmVeiwInfo.Text1.Text = frmVeiwInfo.Text1.Text + Buf & Wrap\$
LineNum = LineNum + 1
If LineNum = MemoLine Then
MemoLine = MemoLine + 11
If UCase(Buf) <> UCase("n") Then
frmVeiwInfo.Text1.Text = ""
Else
Exit Sub
End If
End If
Wend

Close #1

Else
prompt = "C:\PilotInfo\quotes.txt does not exist"
MsgBox (prompt), , "Error"
End If
End Sub

Good Luck
Jo
0

Author Comment

ID: 8191574
That worked great Thx
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
###### Suggested Courses
Course of the Month10 days, 3 hours left to enroll