Click to See Complete Forum and Search --> : Day of the week label


jellylogix
April 9th, 2008, 07:48 PM
i'm making a windows form application in VS 2008 and i'm really new at it. I got the time to display using
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

DateTime dt=System::DateTime::Now;
this->label1->Text::set(dt.ToString());
}

but when i try using this code:
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

DateTime dw=System::DateTime::DayOfWeek;
this->label1->Text::set(dw.ToString());
}

then i receive errors that say:

error C2597: illegal reference to non-static member 'System::DateTime::DayOfWeek'

error C2440: 'initializing' : cannot convert from '' to 'System::DateTime'

I'm really new at Windows forms, and have learned everything through trial and error, but here i'm stumped! i have no idea what a "non-static member" is and why this code won't work... if maybe you could just tell me a code that would return the value of the day of the week (something like "Thursday" so that i can use it in a label. that would be great!

Alex F
April 10th, 2008, 02:51 AM
DateTime dw=System:: DateTime:: Now;
this->label1->Text::set(dw.DayOfWeek.ToString());

Nothing specific to Windows Forms, just C++. DayOfWeek is instance property which requires DateTime instance. This instance is returned by static method Now.

jellylogix
May 4th, 2008, 01:21 PM
thank you so much