Hi
Busy creating with a little program that creates a excel spreadsheet from a sql database but hit a little snag.
Trying to access the text from a datetimepicker in my MainForm class from my CreateExcelClass (seperate .cs file). Tried a few examples I found around the web, didn't work so well.
Not going to explain them all since I'm bad at it and it's going to take alot of space.
Here's what I tried.
MAINFORM:
public string getWaterStartDate()
{
return dateTimePicker3.Text;
}
public string getWaterEndDate()
{
return dateTimePicker4.Text;
}
CREATEEXCELCLASS:
Mainform form = new MainForm();
public void addBetweenDates()
{
try
{
if(strSupply == "W")
{
ws.Cells[5, "B"] = form.getWaterStartDate();
ThrowError("addBetweenDates: " + form.getWaterStartDate());
ws.Cells[6, "B"] = form.getWaterEndDate();
ThrowError("addBetweenDates: " + form.getWaterEndDate());
}
else if (strSupply == "E")
{
}
}
catch (Exception ex)
{
ThrowError(ex.Message.ToString());
}
}
And here is the output I get in my log file:
01/06/2011 02:09:02 PM: addBetweenDates:
01/06/2011 02:09:02 PM: addBetweenDates:
01/06/2011 02:09:02 PM: OpenSheetAfterSave: Opening File: Tyger Valley (01-06-2011).xls
Probably doing something hideously wrong. Any suggestions?
If you need more code just ask.