PC Review


Reply
Thread Tools Rate Thread

For cycle and Extension attribute

 
 
Lucio Menci
Guest
Posts: n/a
 
      29th Jun 2010
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...t.languages.vb
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Attribute 'onchange' is not a valid attribute of element 'TextBox' Joe Kovac Microsoft ASP .NET 2 2nd May 2007 02:11 PM
Validation (XHTML 1.0 Transitional): Attribute 'height' is not a valid attribute of element 'table' perspolis Microsoft ASP .NET 1 23rd Jan 2007 07:57 AM
Validation (XHTML 1.0 Transitional): Attribute 'leftmargin' is not a valid attribute of element 'body'. anonymous Microsoft ASP .NET 1 2nd Aug 2006 09:05 AM
How do I keep result from 1 iteration cycle to use in next cycle? =?Utf-8?B?c2dsOGFrbQ==?= Microsoft Excel Misc 0 27th Jul 2006 08:28 PM
Unrecognized Attribute "appliesTo" in BuildProvider Add Extension =?Utf-8?B?Tm9ybUQ=?= Microsoft ASP .NET 2 21st Nov 2005 03:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:18 AM.