StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ETime  
#1 Posted : Thursday, April 23, 2020 4:03:22 AM(UTC)
ETime

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/16/2020(UTC)
Posts: 7

First, I didn't learn C#, I only have a little programming knowledge.

Code:

clip.Clear();
var old = clip.GetText();
sp.SendKeys("^c");
sp.Sleep(50);
var xin = clip.GetText();
sp.MessageBox(old,"old");
sp.MessageBox(xin,"new");
clip.SetText(old);

This one says, "The value cannot be null."

Code:

clip.Clear();
var old = clip.GetText();
sp.SendKeys("^c");
sp.Sleep(50);
var xin = clip.GetText();
sp.MessageBox(old,"old");
sp.MessageBox(xin,"new");
if (old = null){
    sp.MessageBox("yes","yes");
    clip.SetText(old);
    }
else{
    sp.MessageBox("no","no");
    clip.SetText(old);
}

This one go to MessageBox("no","no") and says, "The value cannot be null."

Why?
liuxilu  
#2 Posted : Thursday, April 23, 2020 7:24:54 AM(UTC)
liuxilu

Rank: Advanced Member

Reputation:

Groups: Translators, Moderators, Approved
Joined: 4/6/2020(UTC)
Posts: 79
China

Thanks: 1 times
Was thanked: 21 time(s) in 21 post(s)
Scrips use js, and the program's written in C#.
You have a = missed.
Code:
if (old == null){

You have clip.Clear(); so there's nothing on the clipboard, so you get null.
ETime  
#3 Posted : Thursday, April 23, 2020 7:48:34 AM(UTC)
ETime

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/16/2020(UTC)
Posts: 7

Code:

if (old = null){
    sp.MessageBox("yes","yes");
    clip.SetText(old);
    }
else{
    sp.MessageBox("no","no");
    clip.SetText(old);
}


Do you see this?Even I add one more =.

This one go to MessageBox("no","no"), it means old not null, right? and than the wrong message says "The value cannot be null".

I use clip.Clear(); because I want to simulate a blank clipboard.

that is why the topic say " restore a blank clipboard"
liuxilu  
#4 Posted : Thursday, April 23, 2020 9:01:42 AM(UTC)
liuxilu

Rank: Advanced Member

Reputation:

Groups: Translators, Moderators, Approved
Joined: 4/6/2020(UTC)
Posts: 79
China

Thanks: 1 times
Was thanked: 21 time(s) in 21 post(s)
It does isn't null, it's "". The error's thrown by the host. “System.Windows.Forms.Clipboard.SetText()” will throw “System.ArgumentNullException” when “text is null or System.String.Empty. ” See .Net source code.

Edited by user Thursday, April 23, 2020 9:06:09 AM(UTC)  | Reason: Not specified

ETime  
#5 Posted : Thursday, April 23, 2020 1:37:10 PM(UTC)
ETime

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/16/2020(UTC)
Posts: 7

thanks, problem solving
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.