Checking Strings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Koolioman
    New Member
    • Oct 2007
    • 11

    Checking Strings

    I want my program to check to see if my string says a certain thing, like a password. I've tried it like this, but it says "comminity call missing argument list". Here's my code.

    Code:
    String^ password = System::Convert::ToString(textBox1->Text);
    
    if (password->Equals == "open sesame");
    MessageBox::Show("Welcome!");
    
    else
    MessageBox::Show("Go away!");
    the problem is in the 3rd line.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by Koolioman
    I want my program to check to see if my string says a certain thing, like a password. I've tried it like this, but it says "comminity call missing argument list". Here's my code.

    Code:
    String^ password = System::Convert::ToString(textBox1->Text);
    
    if (password->Equals == "open sesame");
    MessageBox::Show("Welcome!");
    
    else
    MessageBox::Show("Go away!");
    the problem is in the 3rd line.

    HI,
    There are a couple of issues in the 3rd line.
    1); at the end of the condition(Remov e the ;)
    2)What Equals means
    it shuld be like this
    [code=cpp]
    if(password == "open sesame")

    //or

    if(password.equ als("open sesame")

    [/code]

    Raghuram

    Comment

    • Koolioman
      New Member
      • Oct 2007
      • 11

      #3
      Thank you, I will try that.
      (the semicolon was a typo)

      Comment

      • Koolioman
        New Member
        • Oct 2007
        • 11

        #4
        I got it to work...
        Just so you know, the first example wirked, but the second one didn't.
        (and I noticed the parenthase typo)

        Comment

        Working...