SELECT ALL AND COPY

vb6 Greece
  • 13 years ago

    I HAVE A PROBLEM AND WOULD WANT YOUR HELP. I HAVE A FILE .txt AND I WANT AFTER HIM I OPEN TO MAKE CHOICE OF ALL (select all) AND COPY OF ALL (copy). HOW CAN I DO THAT?

  • 13 years ago
    hi which control are you using to open the file TextBox or RichTextbox regards manpreet singh dhillon hoshiarpur
  • 13 years ago

    any idea?   Wink  i open the .txt with  

    'Open "C:\B' LEVEL\NAMES.TXT" For Input As #4

  • 13 years ago

    I think you're after something like this. 

    Private Sub CopyAll()
        Dim AllString As String
        Dim iFile As Integer
        Dim Line As String
       
        iFile = FreeFile
        Open "C:\Filename.txt" For Input As iFile
        While NOT EOF(ifile)
            Line Input #iFile, Line
            AllString = AllString & Line ' << Marked line see below
        Wend
        Close (iFile)
       
        TextBox.Text = AllString
    End Sub

    This will copy ALL of the text from a file. If you wish to include Character returns (ie if your using a multiline box) you'd want to put in something like below instead of the Marked line:

    If AllString <> vbnullstring then
       AllString = AllString & vbcrlf & Line
    else
        AllString = Line
    end if 

  • 13 years ago

    As others specified For loop is easy to get all the text. One more thing if you want any access errors not to occur, you can open the file in Binary Read Lock Read as #1 , which doesn't give permission to others to access it.

    And use RichTextBox for good performance.

    Ramesh Sambari

  • 13 years ago

    UNFORTUNATELY NO ONE HAS HELPED ME.  MAYBE YOU DID NOT UNDERSTAND WHAT I WANT. 

    THE FRIEND WILLIAMSG USE THE CODE ROUGHLY THAT I USE  BUT THE PROBLEM  IS THAT DATA OF FILE THAT I OPEN AND READ I WANT  TO  PASTE IT IN OTHER NOTEPAND THAT  THE USER WILL OPEN  WITH THE MOUSE.   

       MUST THIS DATA  STORED IN THE CLIPBOARD ?  THAT IS MY PROBLEM

     

    NIKOS

  • 13 years ago

    If you want to read all data from a txt file and paste that manually into notepad then use this code.

    Private Sub CopyAll()
        Dim AllString As String
        Dim iFile As Integer
        Dim Line As String
      
        iFile = FreeFile
        Open "C:\Filename.txt" For Input As iFile
        While Not EOF(iFile)
            Line Input #iFile, Line
            AllString = AllString & Line ' << Marked line see below
        Wend
        Close (iFile)
       
        Clipboard.Clear
        Clipboard.SetText = AllString
    End Sub



     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“I invented the term Object-Oriented, and I can tell you I did not have C++ in mind.” - Alan Kay