how to add days to textbox on activereports 6 and c#

64 Views Asked by At

i have activereport 6 and C# and i try to add 6 days to textbox1 value/text this is what i try

string text1 = this.textbox1.Text;

i also try

string text1 = this.textbox1.Text.ToString();

or string text1 = this.textbox1.Value

convert string to time

DateTime date1 = Datime.Parse(text1);

i keep getting error "target of invocation" how do i convert textbox data string to datetime? or how do i fix that target of invocation error?

1

There are 1 best solutions below

0
MESCIUS Team On

That should be the correct way to get the text value from the textbox, as it is already a string.

string text1 = this.Textbox1.Text;

From there you should be able to use the standard .NET methods to convert it to a DateTime. The way you did it looks correct to me based on Microsoft's docs. However, that's assuming the format your string is in is one of the formats the DateTime.Parse() method understands by default. Example from their docs:

string dateInput = "Jan 1, 2009";
var parsedDate = DateTime.Parse(dateInput);
Console.WriteLine(parsedDate);
// Displays the following output on a system whose culture is en-US:
//       1/1/2009 00:00:00

If your string is in a different format from one of the handful that DateTime.Parse understands by default you may need to use a custom format, and I believe that could be the source of the error you're receiving.