|
-
Dec 1st, 2004, 11:27 PM
#1
Thread Starter
New Member
view txt file
i have create a basic vb application...i using vb6. i got external file in the same folder name a.txt
so how do i can display the text file on the vb application?
-
Dec 1st, 2004, 11:32 PM
#2
Welcome to the Forums.
Here is a link to a Tutorial on File I/O
Instead of showing the file contents to a message box, you can
display it in a textbox by setting the textbox's .Text property to
the value of the variable.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 1st, 2004, 11:52 PM
#3
Software Eng.
Definetly read RobDog's tutorial.
Here's an identical approach in binary mode. It's generally not used with ASCII files, but might prove to be slightly faster for larger files (but who's counting these days).
VB Code:
Dim sTmp As String
sTmp = Space$(FileLen("C:\myfile.txt"))
Open "C:\myfile.txt" For Binary Access Read As #1
Get #1, , sTmp
Close #1
Text1.Text = sTmp
Someone should add binary files to that tutorial.
-
Dec 2nd, 2004, 12:02 AM
#4
Thread Starter
New Member
do i need to add label or listbox to place it on my vb application and i just want to view the text file only...i got a basic application to generate number...so after user click to Generate Command button, a space of showing the text file will be apear...
-
Dec 2nd, 2004, 12:03 AM
#5
Actually Mega, its B-Rabbit/Algar's Tutorial.
Wish I could take the credit though
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 2nd, 2004, 12:04 AM
#6
Software Eng.
No, just a textbox and a commandbutton.
And change the path of the file to reflect the file you want to open.
Where are you getting Label's and ListBoxes from?
-
Dec 2nd, 2004, 12:05 AM
#7
If you have multiple lines of data to display, then using a textbox
with its .Multiline property set to True will do. Also, enable the
scrollbars too.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 2nd, 2004, 12:16 AM
#8
Thread Starter
New Member
Is it like this?
Private Sub Text6_Change()
Dim sTmp As String
sTmp = Space$(FileLen("file.txt"))
Open "file.txt" For Binary Access Read As #1
Get #1, , sTmp
Close #1
End Sub
Last edited by brainwash; Dec 2nd, 2004 at 12:26 AM.
-
Dec 2nd, 2004, 12:20 AM
#9
Software Eng.
Put it in a command button's click() event, not the change() event of your textbox.
-
Dec 2nd, 2004, 12:32 AM
#10
Thread Starter
New Member
nothing appear on the textbox...my textbox name is Text6
-
Dec 2nd, 2004, 12:39 AM
#11
Software Eng.
Did you specify the correct path?
Did you add
Text6.Text = sTmp
at the end of your code?
-
Dec 2nd, 2004, 12:42 AM
#12
Thread Starter
New Member
-
Dec 2nd, 2004, 01:38 AM
#13
brainwash
You can also use an RTF Textbox and not have to write much code to read and display the file. Two to thre lines I believe.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|