|
-
Jul 25th, 2023, 11:31 AM
#1
Thread Starter
Lively Member
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.
-
Jul 25th, 2023, 11:36 AM
#2
Lively Member
Re: Using Clipboard in .NET 7.0
Last edited by themindgoblin; Dec 22nd, 2023 at 10:13 AM.
-
Jul 25th, 2023, 12:46 PM
#3
Thread Starter
Lively Member
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.
-
Jul 25th, 2023, 01:54 PM
#4
Lively Member
Re: Using Clipboard in .NET 7.0
Last edited by themindgoblin; Dec 22nd, 2023 at 10:13 AM.
-
Jul 25th, 2023, 03:30 PM
#5
Re: Using Clipboard in .NET 7.0
 Originally Posted by coffent
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.
-
Jul 25th, 2023, 08:43 PM
#6
Thread Starter
Lively Member
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.
-
Aug 18th, 2023, 01:37 AM
#7
Re: Using Clipboard in .NET 7.0
 Originally Posted by coffent
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|