Algorithm - Activate the Push Button
Return


  1. Algorithm (void CTestVC0Dlg::OnDisplay()):


  2. Text Code (void CTestVC0Dlg::OnDisplay()):

    // TestVC0Dlg.cpp : implementation file
    //
    ...
    .............................................................................................................................................
    .............................................................................................................................................
    void CTestVC0Dlg::OnDisplay() 
    {
    CString vrecordno, vtextdata, vbook, vtitle, vchapter, vverse;
    CString upperword,lowerword, leftword, rightword, ulword;
    long recordno;
    char chrrecno[40];
    int nNewItem, i, j;
    COleVariant var;
    
    //Recordset declaration
    if (m_pRSW0)
    if (m_pRSW0->IsOpen())
    m_pRSW0->Close();
    
    delete m_pRSW0;
    
    m_pRSW0 = new CDaoRecordset(m_pDB);
    m_pRSW0->Open(dbOpenDynaset, "SELECT * from BibleTable", 0); 
    
    //Set the IDC_DISPLAY button disable
    m_display.EnableWindow(FALSE);
    
    UpdateData(TRUE);
    
    //Clear the list control
    m_searchlist.DeleteAllItems();
    m_staticfound = "";
    
    //Uppercase style 
    upperword = m_edword;
    upperword.MakeUpper();
    
    //Lowercase style
    lowerword = m_edword; 
    lowerword.MakeLower();
    
    //Uppercase + lowercase style
    leftword = m_edword.Left(1);
    rightword = m_edword.Right(m_edword.GetLength() - 1); 
    leftword.MakeUpper();
    rightword.MakeLower();
    ulword = leftword + rightword;
    
    i = 0;
    m_pRSW0->Move(2);
    
    //Max items to found = 4999 
    while (!m_pRSW0->IsEOF() && i < 5000)
    { 
    
    	//Value of TextData field
    	var = m_pRSW0->GetFieldValue(_T("TextData"));
    	vtextdata = CString(V_BSTRT(&var));
    	
    	//Search condition 
    	if ((vtextdata.Find(upperword) != -1) || (vtextdata.Find(lowerword) != -1) || (vtextdata.Find(ulword) != -1))
    	{
    		//Absolute position of record
    		recordno = m_pRSW0->GetAbsolutePosition();
    
    		//Convert long to string
    		ltoa(recordno,chrrecno,10);
    		vrecordno = CString(chrrecno);
    		
    		//Value of Book field
    		var = m_pRSW0->GetFieldValue(_T("Book"));
    		vbook = CString(V_BSTRT(&var));
    		
    		//Value of Title field
    		var = m_pRSW0->GetFieldValue(_T("BookTitle"));
    		vtitle = CString(V_BSTRT(&var)); 
    		
    		//Value of Chapter field
    		var = m_pRSW0->GetFieldValue(_T("Chapter"));
    		vchapter = CString(V_BSTRT(&var));
    		
    		//Value of Verse field
    		var = m_pRSW0->GetFieldValue(_T("Verse"));
    		vverse = CString(V_BSTRT(&var));
    		
    		//Insert item to List control
    		nNewItem = m_searchlist.InsertItem(i,vrecordno,1);
    		m_searchlist.SetItem(nNewItem,1,LVIF_TEXT,vbook,0,0,0,0);
    		m_searchlist.SetItem(nNewItem,2,LVIF_TEXT,vtitle,0,0,0,0);
    		m_searchlist.SetItem(nNewItem,3,LVIF_TEXT,vchapter,0,0,0,0);
    		m_searchlist.SetItem(nNewItem,4,LVIF_TEXT,vverse,0,0,0,0);
    		
    		i = i + 1;
    		j = i - 1;
    	}
    	m_pRSW0->MoveNext();
    	
    }
    
    //Information about Items found 
    if (i == 0)
    	m_staticfound = "0 item found.";
    else
    {
    	itoa(j+1 ,chrrecno,10);
    	if (j >= 4999)
    		m_staticfound = "More then " + (CString)chrrecno + " items found."; 
    	else
    		m_staticfound = (CString)chrrecno + " items found."; 
    }
    
    UpdateData(FALSE);
    // TODO: Add your control notification handler code here
    
    }
    .............................................................................................................................................
    .............................................................................................................................................
    ...
Return