Syntax Error. Take a closer look at the code.
if (comboBox1.SelectedItem) is "1+x";
==> if (comboBox1.SelectedItem is "1+x") {
// insert your code here...
}
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I need help with IF in my code and tried almost everything that I found on youtube tutorials but nothing worked.
I want to code that way, when I choose from comboBox1 item1 (1+x) and apply it it will type /example 60, when I choose from combobox item2 (5+y) it will type /example 300
Here is code
private void NEXT_Click(object sender, EventArgs e)
{
{
if (comboBox1.SelectedItem) is "1+x";
t = " 60";
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
SendKeys.Send("/timeout " + richTextBox1.Text + t);
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3));
SendKeys.Send("{ENTER}");
}
{
if (comboBox1.SelectedItem) = "5+y";
t = " 300";
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
SendKeys.Send("/timeout " + richTextBox1.Text + t);
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3));
SendKeys.Send("{ENTER}");
}
}
Syntax Error. Take a closer look at the code.
if (comboBox1.SelectedItem) is "1+x";
==> if (comboBox1.SelectedItem is "1+x") {
// insert your code here...
}
Hi, @IAKIL
Try to use equality operators: ==
instead of =
.
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.