How to text file items in a listbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lee123
    Contributor
    • Feb 2007
    • 556

    How to text file items in a listbox

    i have been working on a database and i was hoping someone out there can tell me how i can list the things in a listbox to text file in notepad i have tried everything i know but i still cant do it? i have used

    Code:
    Dim ff As String
        ff = FreeFile
        Me.Refresh
        Open "C:\AutoMaintenance.log" For Append As #ff
            Print #ff, "Vehicles Owns" & "    " & VehicleList
        Close #ff
    but still nothing is there a way to do this please help!!

    lee123
  • Mihail
    Contributor
    • Apr 2011
    • 759

    #2
    Can you print the same thing in Immediate window ?
    In the other words, are you very very sure that is there something to append to external file ?

    Comment

    • lee123
      Contributor
      • Feb 2007
      • 556

      #3
      well when i do it, it says "bad file name" but there is some thing in the listbox. so why doesnt it print. i mean if there is something in the listbox it should print right?

      Comment

      • Mihail
        Contributor
        • Apr 2011
        • 759

        #4
        ff is NOT a string because FreeFile return a numeric value.
        I don't know exactly if it is an integer or a long.
        So remove As String from DIM statement in order to dimension ff as a variant (the default dimension if you don't specify any dimension).

        Let me know if steel not work and I'll take a closer look in order to help you.

        Comment

        • lee123
          Contributor
          • Feb 2007
          • 556

          #5
          well i have tried that and others but nothing? on my form i have textboxes and they seem to show up but its just the information in the listbox dont so thats why i used the "STRING" function, i guess there isnt a way to do that

          lee123

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            @Lee.
            I'm not sure why you're still posting questions with most of the information missing after over 500 posts.

            What's going wrong and where?
            What's the value of [VehicleList] at the time line #5 is executed?

            So much time and effort wasted for the want of a few minutes preparation on your part.

            Comment

            • lee123
              Contributor
              • Feb 2007
              • 556

              #7
              hmm.. Neopa, what's going wrong is that it shows nothing when it is executed everything else shows up but the items in the listbox. the line comes out blank. when you do the textboxes that are on the form the information shows up. but the way i was shown it doesnt work (the listbox information not the textboxes) all i wanted to know is how do you get the information from the listbox to print in notepad. the information i want to show is. (year, make, model,engine) because that is whats in the listbox but nothing.but if its "so much time and effort wasted then i am sorry for posting such a question" ill find someone else to answer the question somehow. because i thought i did explain it good in the first post, but i guess i didnt.

              lee123

              Comment

              • Mihail
                Contributor
                • Apr 2011
                • 759

                #8
                This code will do your job (see attachment).
                Of course you must adapt it to your needs.

                Good luck !

                PS
                My ListBox is a MultiSelect one.
                Attached Files

                Comment

                • lee123
                  Contributor
                  • Feb 2007
                  • 556

                  #9
                  Mihail, thanks for the file i will look at it.

                  lee123

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32633

                    #10
                    @Lee.
                    I found your response very difficult to make any sense of, as any punctuation, where it was used, was done so erroneously, and resulted in something quite indecipherable without even more effort. Only one of my questions even appears to have an attempted answer, so I'll leave you to other experts here, but please understand that, as a moderator, I won't just go away. All our experts deserve protection from such casually off-hand members, and please understand they will get it while I'm around.

                    Comment

                    • lee123
                      Contributor
                      • Feb 2007
                      • 556

                      #11
                      Mihail, Thank you for your help. It works just like a charm.

                      @Neopa, sorry for not punctuating my words but you are an educated man i see, as for me not so much. I Know you meant well and i appriciate it. I know your just doing your job sorry next time ill put my questions in the right form.

                      lee123

                      Comment

                      Working...