如何实现以逗号隔开组成多值字段查询
strtok实现! 
知道的高手 给个例子!

解决方案 »

  1.   

    void QueryResults::OnChangeEdit1() 
    {
        //2010-12-07
        CString    editstr;
        m_list.DeleteAllItems();
        UpdateTable();
        m_local.GetWindowText(editstr);
        
        if(editstr.IsEmpty())
        {
            return;
        }
        if (editstr == _T(" "))
        {
            return;
        }
        
        
        for(int i=0;i<m_list.GetItemCount();i++)
        {
            CString listitemstr=m_list.GetItemText(i,2);
            
            
            if(listitemstr.Find(editstr)!=-1)//找到
            {
                m_list.DeleteItem(i); 
                i--;        }    
        }}
      

  2.   


    #include <string.h>
    #include <stdio.h>char string[] = "A string\tof ,,tokens\nand some  more tokens";
    char seps[]   = " ,\t\n";
    char *token;void main( void )
    {
       printf( "%s\n\nTokens:\n", string );
       /* Establish string and get the first token: */
       token = strtok( string, seps );
       while( token != NULL )
       {
          /* While there are tokens in "string" */
          printf( " %s\n", token );
          /* Get next token: */
          token = strtok( NULL, seps );
       }
    }