Tuesday, August 31, 2010
CArray Members
CString Methods at MSDN
BSTR GetBSTR()
{
_bstr_t bstr1(_T("This is the test string."));
BSTR bstr; bstr = bstr1.copy();
return bstr;
}
CComBSTR GetComBSTR()
{
CComBSTR bstr("This is the test string.");
return bstr;
}
void CVbsDlg::ShowBSTR(BSTR bstr)
{
_bstr_t bstrStart(bstr);
CString s;
s.Format(_T("%s"), (LPCTSTR)bstrStart); AfxMessageBox(s);
}
COleDateTime:: Format
DATE Description and Use
Friday, August 27, 2010
CArray CString Example
#include <Afxwin.h>
#include <Afxtempl.h>
void main()
{
CString l_strValue;
CArray<CString,CString> l_CArray;
for(int i=0;i< 20; i++)
{//Use the CString format function to create different values
l_strValue.Format("Value %d",i);
//Add the formatted CString to CArray
l_CArray.Add(l_strValue);}
}
#include <Afxwin.h>
#include <Afxtempl.h>
void main()
{
CString l_strValue;
CArray<CString,CString> l_CArray;
for(int i=0;i< 20; i++)
{//Use the CString format function to create different values
l_strValue.Format("Value %d",i);
//Add the formatted CString to CArray
l_CArray.Add(l_strValue);}
//This part takes care of accessing and printing the data from CArray
CString l_strGetVal;
for(i=0;i<=l_CArray.GetUpperBound();i++)
{
l_strGetVal = l_CArray.GetAt(i);
printf("%s\n",l_strGetVal);
}
}
l_CArray.RemoveAll() //This will remove all the elements from CArray
l_CArray.RemoveAt(10); //This will remove the 10th element from CArray