-
Mar 23rd, 2025, 12:11 PM
#1
Thread Starter
Addicted Member
l am stuck
l would like to read the content of a Text file which is at folder C and have it's contents appearing in a Label
App.Path & \folderA\folderB\folderC
Thanks for help
-
Mar 23rd, 2025, 12:25 PM
#2
Re: l am stuck
Have you tried the basic VB6 file io methods?
-
Mar 23rd, 2025, 12:32 PM
#3
Re: l am stuck
Code:
Private Sub Form_Load()
With New Scripting.FileSystemObject
With .OpenTextFile(App.Path & "\folderA\folderB\folderC\file.txt")
Label1 = .ReadAll
.Close
End With
End With
End Sub
Requires a reference to "Microsoft Scripting Runtime".
-
Mar 23rd, 2025, 02:47 PM
#4
Thread Starter
Addicted Member
Re: l am stuck
Requires a reference to "Microsoft Scripting Runtime".
What exactly do you mean . l know nothing about it . Never used it
-
Mar 23rd, 2025, 02:48 PM
#5
Re: l am stuck
You select it from the Project menu and then References.
-
Mar 24th, 2025, 03:39 AM
#6
Thread Starter
Addicted Member
-
Mar 24th, 2025, 04:20 AM
#7
Re: l am stuck
Code:
Sub Something()
Dim f As Integer
Dim s As String
f = FreeFile
Open "C:\Folder A\Folder B\Folder C\test.txt" For Input As #f
Line Input #f, s
Close #f
MyLabel.Caption = s
End Sub
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Mar 24th, 2025, 05:44 AM
#8
Thread Starter
Addicted Member
Re: l am stuck
Thanks Zvoni , it does not work , maybe l was not very explicit .
l have a folder "Recovery" in it 2 folders "MyPics" and "MyTexts"
in "myPics" folder there are 50 photos, p1.jpg , p2.jpg , p3.jpg... etc
In "myTexts" folder there are 50 texts , t1.txt , t2.txt,t3.txt... etc
Altough l have been able to get the photos with
Foto = "p" + PhotoNum + (".jpg")
PicBase.Picture = LoadPicture(App.Path & "" & "\recovery" & "\mypics" & "" & Foto)
It goes without saying , that t1.txt is a description of photo p1.jpg
l have no luck to present the contents of t1.txt etc in a new text or label
Still trying
-
Mar 24th, 2025, 05:55 AM
#9
Lively Member
Re: l am stuck
Try:
Code:
Private Sub Command1_Click()
Dim sPath As String
sPath = App.Path & "\folderA\folderB\folderC\test.txt" 'change accordingly
With CreateObject("scripting.Filesystemobject").opentextfile(sPath, ForReading)
Label1.Caption = .readall
.Close
End With
End Sub
-
Mar 24th, 2025, 06:18 AM
#10
Thread Starter
Addicted Member
-
Mar 24th, 2025, 06:34 AM
#11
Re: l am stuck
You are stuck, I am stuck, we are all stuck in something or other - that doesn't really help much.
You are particularly stuck in this case with raising post using a misleading and unhelpful subject. If you truly want good targetted help, learn to place a precis of the problem in the subject so we know what you are stuck with. More people will be likely to help.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Mar 24th, 2025, 07:03 AM
#12
Re: l am stuck
and i doubt this very much:
Spot the "mistake"
Code:
Foto = "p" + PhotoNum + (".jpg")
PicBase.Picture = LoadPicture(App.Path & "" & "\recovery" & "\mypics" & "" & Foto)
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Mar 24th, 2025, 07:04 AM
#13
Thread Starter
Addicted Member
Re: l am stuck
See my post #8 . l think l was preciise enough
-
Mar 24th, 2025, 07:06 AM
#14
Re: l am stuck
 Originally Posted by vbgeobas
See my post #8 . l think l was preciise enough
Code:
Sub Something(ByVal PhotoNum As Long)
Dim f As Integer
Dim s As String
f = FreeFile
Open App.Path & "\recovery\mytexts\t" & cstr(PhotoNum) & ".txt" For Input As #f
Line Input #f, s
Close #f
MyLabel.Caption = s
End Sub
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Mar 24th, 2025, 07:45 AM
#15
Thread Starter
Addicted Member
Re: l am stuck
l did not copy/paste the line ,sorry , but like l said it works perfectly with the photos
No go , Zvoni , thanks for tryng to help .
-
Mar 24th, 2025, 07:54 AM
#16
Lively Member
Re: l am stuck
When you say it's not working, do you get an error?
Are you able to attach an example text file?
-
Mar 24th, 2025, 08:05 AM
#17
Thread Starter
Addicted Member
Re: l am stuck
 Originally Posted by AdorablePlum
When you say it's not working, do you get an error?
Are you able to attach an example text file?
No error .The label is just blank .
It will be all Greek to you .
t1.txt= ???????????? ??? ?????? That was supposed to be Greek
Whch actually means SUNSET AT FALIRO (Southern suburbs of AThens)
Last edited by vbgeobas; Mar 24th, 2025 at 08:09 AM.
-
Mar 24th, 2025, 08:09 AM
#18
Re: l am stuck
Put English text in the text files if you want it displayed in a label. Greek text won't work.
-
Mar 24th, 2025, 08:19 AM
#19
Thread Starter
Addicted Member
Re: l am stuck
It works with Englih text. Thank you a lot , but it's not the solution .
The project is supposed to be used by Greeks
l'll keep trying
-
Mar 24th, 2025, 08:25 AM
#20
Re: l am stuck
 Originally Posted by vbgeobas
It works with Englih text. Thank you a lot , but it's not the solution .
The project is supposed to be used by Greeks
l'll keep trying
https://www.vbforums.com/showthread....o-OCX-required
and FWIW: It needed 17 Posts, until OP said his captions are NOT in ANSI....
so at the end of the Day, the Problem wasn't with File I/O, but that it's Unicode....
lesson learned: "It doesn't work" is NOT an error-description
Last edited by Zvoni; Mar 24th, 2025 at 08:30 AM.
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Mar 24th, 2025, 11:45 AM
#21
Lively Member
Re: l am stuck
Instead of a label, can you use a locked textbox?
-
Mar 24th, 2025, 05:05 PM
#22
Re: l am stuck
No point in trying to help this bloke. He can't even help himself. It is a lost cause.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Mar 25th, 2025, 04:07 AM
#23
Re: l am stuck
Use twinBASIC; then you don't need to worry about supporting Unicode in an ANSI world with 3rd party controls and API file i/o, just tag the Open statement with the encoding, e.g. Open "C:\MyFile.txt" For Input Encoding utf-8 As #1 then load into labels and textboxes with native Unicode support
-
Mar 25th, 2025, 09:47 AM
#24
Fanatic Member
Re: l am stuck
"i am stuck" AND "it doesn't work"
Not to pile on but to agree with what others have said to you...
These don't work as a description of the problem you're having when you're asking for help.
Don't go into QA my friend - writing up a bug ticket with that description would quickly get you in the doghouse with developers. 
As a developer yourself, imagine a user of your software saying that to you. Wouldn't you want much more detail and precision?
So it sounds like the issue you're having currently is displaying Greek text in a label? VB6 controls don't support that natively. Check out the Visual Basic Common Controls Replacement project (VBCCR) - I use those controls rather than VB6's to support multiple languages in my projects.
-
Mar 25th, 2025, 09:52 AM
#25
Re: l am stuck
 Originally Posted by AAraya
Not to pile on but to agree with what others have said to you...
These don't work as a description of the problem you're having when you're asking for help.
Don't go into QA my friend - writing up a bug ticket with that description would quickly get you in the doghouse with developers. 
Reminds me of the maintainance-reports of Qantas-Airline....
Pilot (On Report-Form): "Something lose in the Cockpit"
Engineer (answers on Form): "Something tightened in the Cockpit"
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
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
|