Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem in Opening .text file with VB6

Status
Not open for further replies.

Bluestar88

Member level 3
Member level 3
Joined
Oct 17, 2014
Messages
59
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
447
Hi guys, I used the code below..The code seems to be correct but it doesn't work, in another word it doesn't enter to the loop..please help me...
Code:
Private Sub Command2_Click()
          Dim AllText, OneLine As String
          FileName = App.Path & "\" & Text1.Text & ".txt"
          MousePointer = 11
          Open FileName For Output As #1
          Form1.Text2.Text = ""
          AllText = ""
          Do While Not EOF(1)
             Line Input #1, OneLine
             AllText = AllText & OneLine '& Chr(13) & Chr(10)
          Loop
         Form1.Text2.Text = AllText
         Close #1
         MousePointer = 0
End Sub
 

hi,
The FileName looks incorrect.?
It would give Text1.text.txt .???
E
You should have Error trap code in the Subroutine
 

hi,
The FileName looks incorrect.?
It would give Text1.text.txt .???
E
You should have Error trap code in the Subroutine


What does it mean about its name? please describe more.
I tested it, yet the condition of loop is false and it doesn't work (loop doesn't work)
Please help me...
 

hi,
Try this, the Text1.txt is located in the App.Path, you were opening the filename for Output

Code:
Private Sub Command2_Click()
          Dim AllText, OneLine, filename As String
          
          On Error GoTo fail1
          
          filename = App.Path & "\[B][COLOR="#FF0000"]" & "Text1" & ".txt"[/COLOR][/B]
          
          
          MousePointer = 11
          
          Open filename For[B][COLOR="#FF0000"] Input[/COLOR][/B] As #1
          Text2.Text = ""
          AllText = ""
          
          Do While Not EOF(1)
             Line Input #1, OneLine
             AllText = AllText & OneLine '& Chr(13) & Chr(10)
          Loop
        Text2.Text = AllText
         Close #1
        MousePointer = 0
         
Exit Sub

fail1:
Text2.SelText = filename
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top