Rank: Newbie
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?
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79 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. You have clip.Clear(); so there's nothing on the clipboard, so you get null.
|
|
|
|
Rank: Newbie
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"
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79 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
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 4/16/2020(UTC) Posts: 7
|
|
|
|
|
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.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close