Friday, February 24, 2012

covert this C# to Vb.Net for Code

Hello,

This is my code in C#

DateTime sYear = new DateTime(Now(),1,1);

DateTime q1Start = sYear;

DateTime q2Start = sYear.AddMonths(3);

DateTime q3Start = sYear.AddMonths(6);

DateTime q4Start = sYear.AddMonths(9);

DateTime q1End = q2Start.AddDays(-1);

DateTime q2End = q3Start.AddDays(-1);

DateTime q3End = q4Start.AddDays(-1);

DateTime q4End = sYear.AddYears(1).AddDays(-1);

Can anyone convert this to VB.Net so that I can use it in "Code" section of the Reporting Services. I tried a VB-C# converter but Reporting Services did not like DateTime datatype.

Any help?

Try the following:

Dim sYear As New System.DateTime(Now(),1,1)
Dim q1Start As System.DateTime = sYear
Dim q2Start As System.DateTime = sYear.AddMonths(3)
Dim q3Start As System.DateTime = sYear.AddMonths(6)
Dim q4Start As System.DateTime = sYear.AddMonths(9)
Dim q1End As System.DateTime = q2Start.AddDays(-1)
Dim q2End As System.DateTime = q3Start.AddDays(-1)
Dim q3End As System.DateTime = q4Start.AddDays(-1)
Dim q4End As System.DateTime = sYear.AddYears(1).AddDays(-1)

HTH

|||That conversion was not that hard. Just a pointer, most of the time all you have to do is remove the ; from the c# code but there is quite a bunch of stuff that you still have to convert.|||

Here is a link you might find very hand to convert in either direction:

http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx

No comments:

Post a Comment