none
Use Clipboard in console app RRS feed

  • Question

  • Have a simple (I hope) requirement to use the Clipboard in a console app.  No amount of imports seems to work for me.

    Lloyd Sheen

    Monday, August 20, 2018 2:07 PM

Answers

All replies

  • When you say it doesn't work, please be more specific. 

    For instance if you said "this was not working" we have something to go by.

    Imports System.Windows.Forms
    
    Module Module1
        Sub Main()
            Clipboard.SetText("Hello")
            Console.ReadLine()
        End Sub
    End Module
    

    And you should be using the following with the arrow.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Monday, August 20, 2018 2:10 PM
    Moderator
  • Doesn't compile.

    Imports System.Windows
    
    Module Module1
    
        Sub Main()
            clipboard.SetText("test")
        End Sub
    
    End Module
    

    The one line of the app fails as it cannot find Clipboard in the System.Windows namespace (where it is supposed to be).


    Lloyd Sheen

    Monday, August 20, 2018 2:20 PM
  • The one line of the app fails as it cannot find Clipboard in the System.Windows namespace (where it is supposed to be).

    It is 

    System.Windows.Forms

    (and Clipboard, not clipboard)

    Monday, August 20, 2018 2:40 PM
  • This fails as well.
    Imports System.Windows.Forms
    
    Module Module1
    
        Sub Main()
            clipboard.SetText("test")
        End Sub
    
    End Module
    


    Lloyd Sheen

    Monday, August 20, 2018 2:44 PM
  • Add a Reference to  System.Windows.Forms
    • Marked as answer by sqlguy Monday, August 20, 2018 3:16 PM
    Monday, August 20, 2018 3:00 PM
  • That did it.  Thanks

    Lloyd Sheen

    Monday, August 20, 2018 3:16 PM