Results 1 to 25 of 25

Thread: l am stuck

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    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

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,481

    Re: l am stuck

    Have you tried the basic VB6 file io methods?

  3. #3
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,337

    Wink 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".

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    Re: l am stuck

    Requires a reference to "Microsoft Scripting Runtime".

    What exactly do you mean . l know nothing about it . Never used it

  5. #5

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    Re: l am stuck

    Sorry , it doesn't work

  7. #7
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,010

    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

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    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

  9. #9
    Lively Member
    Join Date
    Aug 2024
    Posts
    69

    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

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    Re: l am stuck

    Thanks but No Luck .

  11. #11
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,987

    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.

  12. #12
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,010

    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

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    Re: l am stuck

    See my post #8 . l think l was preciise enough

  14. #14
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,010

    Re: l am stuck

    Quote Originally Posted by vbgeobas View Post
    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

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    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 .

  16. #16
    Lively Member
    Join Date
    Aug 2024
    Posts
    69

    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?

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    Re: l am stuck

    Quote Originally Posted by AdorablePlum View Post
    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.

  18. #18

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    185

    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

  20. #20
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,010

    Re: l am stuck

    Quote Originally Posted by vbgeobas View Post
    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

  21. #21
    Lively Member
    Join Date
    Aug 2024
    Posts
    69

    Re: l am stuck

    Instead of a label, can you use a locked textbox?

  22. #22
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,987

    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.

  23. #23
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,982

    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

  24. #24
    Fanatic Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    679

    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.

  25. #25
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,010

    Re: l am stuck

    Quote Originally Posted by AAraya View Post
    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
  •  



Click Here to Expand Forum to Full Width