Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Problem in Opening .text file with VB6

Status
Not open for further replies.

Bluestar88

Member level 3
Joined
Oct 17, 2014
Messages
59
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
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
 

esp1

Advanced Member level 1
Joined
Sep 4, 2007
Messages
401
Helped
139
Reputation
278
Reaction score
138
Trophy points
1,323
Location
England
Activity points
3,370
hi,
The FileName looks incorrect.?
It would give Text1.text.txt .???
E
You should have Error trap code in the Subroutine
 

Bluestar88

Member level 3
Joined
Oct 17, 2014
Messages
59
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
447
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...
 

esp1

Advanced Member level 1
Joined
Sep 4, 2007
Messages
401
Helped
139
Reputation
278
Reaction score
138
Trophy points
1,323
Location
England
Activity points
3,370
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
 

Bluestar88

Member level 3
Joined
Oct 17, 2014
Messages
59
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
447
Dear esp1,
Thanks, You solved my problem...Thanks
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top