Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I stuck...again :-< I created an COleDateTime variable and a CString variable, I used the .Format function to convert my COleDateTime to CString. I have a CStringArray storing all my cstrings and saving them all to disk, but when I try to populate my form all strings show except the date. My disk file shows the date along with all of cstrings.

Very confused about how this should work.

What are the proper techniques for dealing with dates?


[NEW]

Here is just a portion of the code I'm working with, I would like to set the date in my OnBnClickedOrderButton()to the form (EDIT CONTROL) with the current date, but when I do this I get an assertion error. Where and how should I properly insert the date into my array? I know this is vague, but I don't know how to create the date logic.

PS: I tend to over think things, this is probably very simple to solve, but it eludes me.

C++
//CSpecialOrdersView Construction/Destruction

CSpecialOrdersView::CSpecialOrdersView()
	:CFormView(CSpecialOrdersView::IDD)
	, m_oleDateTime(COleDateTime::GetCurrentTime())
	, m_sOrderDate(_T(""))

void CSpecialOrdersView::OnBnClickedOrderButton()
{
    myDataArray& dataMembers = GetData();
    CEdit* pCtl = &m_wndFirstName;
    CmyData order;
    dataMembers.Add(order);
    m_nDataMember = dataMembers.GetCount() - 1;
    PopulateOrder();
    pCtl->SetFocus();
}

void CSpecialOrdersView::PopulateOrder(void)
{
    myDataArray& dataMembers = GetData();

    m_bSettingData = TRUE;
    
    if(dataMembers.GetCount() > 0)
    {
        m_wndOrderDate.SetWindowTextW(dataMembers[m_nDataMember].m_sOrderDate);
        m_wndOrderDate.EnableWindow(TRUE);
        ....
        ....
        ....
Posted
Updated 2-Jan-12 17:31pm
v2
Comments
Chandrasekharan P 3-Jan-12 0:05am    
Did you try to debug and check what is the value that you are getting for date variable?
DrBones69 3-Jan-12 22:27pm    
How do I do that?
Chandrasekharan P 3-Jan-12 23:35pm    
Put a breakpoint on OnBnClickedOrderButton and do a click on F10 to go step by step to know the values of each string.
DrBones69 4-Jan-12 0:03am    
Thanks Chandrasekharan, I'll try debugging for future projects, I'm not good with the whole debugging thing , YET ;-)

OH, I've solved my problem! I think it was a bug in VS2010?

If you expect help, please post some relevant code and clearly indicate the place where it doesn't work.
 
Share this answer
 
Comments
DrBones69 2-Jan-12 23:32pm    
I've added some code...
You are using unitialized data. Maybe you want to do it this way (I can't know exactly from your code portions):

// Uninitialized data
CmyData order;
// Initiliaze data
COleDateTime dt(COleDateTime::GetCurrentTime);
order.m_sOrderDate = dt.Format();
// Add data to array
dataMembers.Add(order);
// Get index of added data
m_nDataMember = dataMembers.GetCount() - 1;
// Access just added data
PopulateOrder();
 
Share this answer
 
Comments
DrBones69 3-Jan-12 21:04pm    
// Initialization is done in the construction.
CmyData order; // Each member is initialized like so...m_sFirstName(_T(""));
I may have run into a bug in VS2010. As I was trying to figure out my date logic I decided to see if I just type in the date to see if it would work that way, it did not work! Soooo, I removed my edit box deleted all variables, pDX, controls, serialization, class date member...anything to do with my setup and then recreated everything. It works just fine after doing this, not sure exactly what might have caused this kind of behavior. STRANGE!?!?

Thanks for your input :-)

DrB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900