Results 1 to 7 of 7

Thread: Using Clipboard in .NET 7.0

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    75

    Using Clipboard in .NET 7.0

    As a very occasional and self-taught programmer, I've written apps under .NET Framework 4.7.2. To use the statement

    Dim text as String = Clipboard.GetText()

    under that framework it's necessary to include the statement: Imports System.Windows.Forms

    When I try to write an app under .NET 7.0 with the same Clipboard statement as above I get an error message saying Clipboard is not declared, with a potential fix being

    Imports System.Windows.Forms (from System.Windows.Forms)

    When I try to apply the recommended fix, nothing happens. If I manually insert Imports System.Windows.Forms I get a message saying the statement is unnecessary. And in any case it doesn't fix the problem. Unlike with .NET 4.7.2, System.Windows.Forms is not listed under References/General.

    I'm obviously missing something fundamental. How can I use the Clipboard under 7.0? Thanks.

  2. #2
    Lively Member
    Join Date
    Jun 2023
    Posts
    79

    Re: Using Clipboard in .NET 7.0

    ....
    Last edited by themindgoblin; Dec 22nd, 2023 at 10:13 AM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    75

    Re: Using Clipboard in .NET 7.0

    Thanks for the suggestion. I tried
    Code:
    Dim text as String = My.computer.clipboard.gettext()
    and still get an error message,
    Code:
    'computer' is not a member of 'Test.My'
    (where "Test" is the name of the app). Note the absence of capitalization showing key words are not being recognized.

  4. #4
    Lively Member
    Join Date
    Jun 2023
    Posts
    79

    Re: Using Clipboard in .NET 7.0

    ....
    Last edited by themindgoblin; Dec 22nd, 2023 at 10:13 AM.

  5. #5
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,958

    Re: Using Clipboard in .NET 7.0

    Quote Originally Posted by coffent View Post
    As a very occasional and self-taught programmer, I've written apps under .NET Framework 4.7.2. To use the statement

    Dim text as String = Clipboard.GetText()

    under that framework it's necessary to include the statement: Imports System.Windows.Forms

    When I try to write an app under .NET 7.0 with the same Clipboard statement as above I get an error message saying Clipboard is not declared, with a potential fix being

    Imports System.Windows.Forms (from System.Windows.Forms)

    When I try to apply the recommended fix, nothing happens. If I manually insert Imports System.Windows.Forms I get a message saying the statement is unnecessary. And in any case it doesn't fix the problem. Unlike with .NET 4.7.2, System.Windows.Forms is not listed under References/General.

    I'm obviously missing something fundamental. How can I use the Clipboard under 7.0? Thanks.
    Did you create a Windows Desktop app? If so then you original code should work, certainly did when I just tried it.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    75

    Re: Using Clipboard in .NET 7.0

    Of course! I was creating the project as a Console App, not a Console App (.NET Framework). When I switched to the latter, everything worked fine. Dumb mistake! Thanks all for your help.

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Using Clipboard in .NET 7.0

    Quote Originally Posted by coffent View Post
    Of course! I was creating the project as a Console App, not a Console App (.NET Framework). When I switched to the latter, everything worked fine. Dumb mistake! Thanks all for your help.
    NET Framework is used to create Windows desktop and server-based applications. This includes ASP.NET web applications. On the other hand, . NET Core is used to create server applications that run on Windows, Linux and Mac. There is no simple method of accessing the clipboard in .net core

Tags for this Thread

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