admin管理员组

文章数量:1123010

i tried to utilise the root symbol in my windows form calculator using a combobox. excuse me for the messy code.

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    float x, y, z;
    bool err = false;
    x = int::Parse(textBox1->Text);
    y = int::Parse(textBox3->Text);
         if (comboBox1->SelectedItem->ToString() == "+") z = x + y;
    else if (comboBox1->SelectedItem->ToString() == "-") z = x - y;
    else if (comboBox1->SelectedItem->ToString() == "/") z = x / y;
    else if (comboBox1->SelectedItem->ToString() == "*") z = x * y;
    else if (comboBox1->SelectedItem->ToString() == "^") z = pow(x, y);
    else if (comboBox1->SelectedItem->ToString() == "√") z = sqrt(x);
        // if (comboBox1->SelectedItem->ToString() == "/" && y == 0) err = true;
    if (err == true) textBox4->Text = "error";
    else textBox4->Text = z.ToString();
}

i simply used the unicode symbol in both the code and the combobox items list. it should've passed the if statement and simply squared x and given z, however the program just does not calculate anything (which by my guess, it doesn't pass the if statement because if i replace square root symbol with a regular char it works perfectly)

本文标签: comboboxis there any possibility of utilising unicode characters in c codeStack Overflow