From: Lucio Menci on
Hi,

1.

In VB2010 the type (T) of the control variable of a For...Next cycle must
have the following operators:
Public Shared Operator >= (op1 As T, op2 As T) As B
Public Shared Operator <= (op1 As T, op2 As T) As B
Public Shared Operator - (op1 As T, op2 As T) As T
Public Shared Operator + (op1 As T, op2 As T) As T

I suggest to agree the use of For...Next cycle in that way:
Dim X1 As T
Dim X2 As T
Dim X3 As U
For X As T = X1 To X2 Step X3
....
Next X
Where is defined:
Public Shared Operator - (op1 As T, op2 As U) As T
Public Shared Operator + (op1 As T, op2 As U) As T

2.

The Extension attribute must be specified in a Module. I cannot use Shared
modifier in a Module. Then I cannot extend shared methods and properties. I
cannot also extend operators (that must be declared shared). The lexer should
ignore warnings for shared and operators routines in modules if they have
Extend attribute.

1+2.

I shuld define:
Public Module Pippo
<Extend> Public Shared Operator +(X As DateTime, Y As TimeSpan) As DateTime
Return X.Add(Y)
End Operator
<Extend> Public Shared Operator -(X As DateTime, Y As TimeSpan) As DateTime
Return X.Subtract(Y)
End Operator
End Module

to use a For...Next cycle like this:
For AvailableDays As Date = FirstDay To LastDay Step New TimeSpan(1, 0, 0, 0)
...
Next AvailableDays

Do you like this?

Thank you

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?mid=d559c0ed-16a1-4885-8117-e1cb6eae31de&dg=microsoft.public.dotnet.languages.vb