Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5932965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:54:29+00:00 2026-05-22T14:54:29+00:00

This code takes a string from a dialog box , and compares it to

  • 0

This code takes a string from a dialog box , and compares it to data in a list,and if succesfull sets the selection on the element from list .
The problem i am having is with the if , it works if i only search the first element , if i try to search any other , it just ignore the if condition and goes till the end o the list .

void CMFC1Dlg::OnBnClickedButton6()
{ 
    CString variable;
    cautare.GetWindowTextA(variable);
    variable = variable.MakeLower(); 

    if(variable!="")
    {
        list<Contact*>::iterator seek;
        bool flag = TRUE;
        int i = 0 ;
        while(flag)
        {
             seek = agenda.first_element();

                if( ((CString)((*seek)->getLastName().c_str())).MakeLower() == variable  || 
                    ((CString)((*seek)->getFirstName().c_str())).MakeLower() == variable || 
                    ((CString)((*seek)->getFirstAndLastName().c_str())).MakeLower() == variable ||
                    ((CString)((*seek)->getLastAndFirstName().c_str())).MakeLower() == variable)
                {
                    contactsVariable.SetCurSel(i);
                    this->OnLbnSelchangeList1();
                    flag=FALSE;
                }

                advance(seek,i);
                i++;
                if (i == agenda.list_size())
                {
                    flag = FALSE;
                }

        }
    }
    else
        MessageBox("No text on input ", "Error", MB_ICONERROR | MB_OK);

    cautare.SetFocus();
    cautare.SetWindowTextA("");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:54:29+00:00Added an answer on May 22, 2026 at 2:54 pm

    You are only ever comparing the first element move advance(seek,i); like this:

     while(flag)
     {
         seek = agenda.first_element();
         advance(seek,i);
         ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my computer this code takes 17 seconds (1000 millions times): static void Main(string[]
i found this code at activestate, it takes a string and prints permutations of
So I have this code that takes care of command acknowledgment from remote computers,
Problem Hello all! I have this code which takes my jpg image loops through
So, I have this code that grabs a bunch of data from the database,
I have this code, which contains a BufferedReader and reads the HTML data from
This code takes in users and movies from two separate files and computes a
I have the following code that takes a String of milliseconds (will be from
I am trying to write a custom dialog box that takes a name from
I have this code, that takes a string and splits it into an array:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.