I am using VC++ 2005 Express Edition. I am trying to write the values of three textboxes and a date time picker to a file.
This is the problem area of the file:
#pragma endregion
private: System::Void submit_Click(System::Object^ sender, System::EventArgs^ e) {
ofstream outfile("xxx.dat (I omitted the directory)", ios::app);
outfile << "Employee: " << name->Text << endl; /*employees name, name->text is the value of a text box.*/
outfile << "Time In: " << timein->Text << endl; /*time in of the employee, timein->text is the value of a text box.*/
outfile << "Time Out: " << timeout->Text << endl; /*time out of the employee, timeout->text is the value of a text box.*/
outfile << "Date: " << date_time->Value << endl; /*date of the employee, date_time->Value is the value of a datetimepicker. */
outfile << endl;
outfile.close();
}
};
}
i figured out how to convert the values to strings but I still get the same error message.
The new code (relevant to the problem):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#pragma endregion
private: System::Void submit_Click(System::Object^ sender, System::EventArgs^ e) {
System::String^ Name = name->Text; //convert name to string
System::String^ in = timein->Text; //convert timein to string
System::String^ out = timeout->Text; //convert timeout to string
System::String^ Date = date->Text; //convert date to string (I changed the date time picker to a text box)
ofstream outfile("-------------/Desktop/Calendar.dat", ios::app); //initiate outfile, append to end of specified file
outfile << "Employee: " << Name << endl; //export Name to calendar.dat...
outfile << "Time In: " << in << endl; //export in to calendar.dat...
outfile << "Time Out: " << out << endl; //export out to calendar.dat...
outfile << "Date: " << date << endl; //export date to calendar.dat...
outfile << endl; //add an extra line between employees
outfile.close();
}