i'm so confused

why doesn't this work? textBox4->Text never wants to equal "test"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
		textBox3->Text = "abc";
	}
	private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
		String^ MyString = gcnew String(lib->getString().c_str());
		textBox1->Text = MyString;//MyString = abc
		if (textBox1->Text != textBox4->Text)
		{
			timer2->Enabled = true;
		}
	}
	private: System::Void timer2_Tick(System::Object^  sender, System::EventArgs^  e) {
		textBox1->Text = textBox2->Text;
		if (textBox2->Text == textBox3->Text)
		{
			textBox4->Text = "test";
		}
	}
Last edited on
Are you sure != is comparing object values and not object identities? That is, is it comparing if the operands are two equivalent strings, or if they are the same string object?
well it doesn't matter. i know timer2->Enabled comes out true because textBox1->Text sends its value to textBox2->Text
then if (textBox2->Text == textBox3->Text)
{
textBox4->Text = "test";
}
textBox4->Text isn't equaling to "test" for some reason
oh wait i just double checked you're right it is the !=
i'm comparing if they are equivalent strings
Last edited on
what operator do i put?
I believe .NET strings have have a .Compare() method that behaves like strcmp().
You can use == or != to compare .NET strings - unlike Java. You need only String::Compare for case-insensitive comparison.
https://msdn.microsoft.com/en-us/library/system.string.op_equality(v=vs.110).aspx
Topic archived. No new replies allowed.