Some changes to VB (Whidbey) that may interest you

  • Thread starter Thread starter Chris Dunaway
  • Start date Start date
C

Chris Dunaway

Just got my hands on Whidbey. Here are a few interesting changes that you
may not be aware of:

1. Continue statement on Do, For and While commands

2. Default Instances of certain classes are back (such as forms).

3. Properties can now have mixed access levels. For example you can
declare a property like this:

Public Property SomeVal() As Integer
Get
Return m_val
End Get

Private Set(ByVal Value As Integer)
m_val = Value
End Set
End Property

4. IsNot keyword. Now instead of If Not someObj Is Nothing, you can
write If someObj IsNot Nothing

Not to mention Operator Overloading, Unsigned types, Generics, Partial
types.
 
Chris Dunaway said:
Just got my hands on Whidbey. Here are a few interesting changes
that you may not be aware of:

Only a question: Is it legal to make this informatin public?
 
Just got my hands on Whidbey. Here are a few interesting changes that you
may not be aware of:

1. Continue statement on Do, For and While commands

Wooo! Hooo! Now if they would extend the Continue and Exit XXX
statements to use labels - then they could do away with Goto completely
:) Like Java's labeled breaks and continues...
2. Default Instances of certain classes are back (such as forms).

I personaly can live with out that... Never used 'em in VB.CLASSIC, so
I don't expect to now :) But, it will make a lot of other peoples lives
easier.
3. Properties can now have mixed access levels. For example you can
declare a property like this:

Public Property SomeVal() As Integer
Get
Return m_val
End Get

Private Set(ByVal Value As Integer)
m_val = Value
End Set
End Property

Nice... Not essential, but it makes mixed access conceptualy cleaner
then having a public property Get, private method setter...
4. IsNot keyword. Now instead of If Not someObj Is Nothing, you can
write If someObj IsNot Nothing

Lame...

Not to mention Operator Overloading, Unsigned types, Generics, Partial
types.

Wooo! Hoooo! Especially the unsigned types and generics.
 
Only a question: Is it legal to make this informatin public?

Well, I never signed any NDA and a quick read of the eula doesn't seem to
indicate that I cannot post this information. This DVD was the same one
given out at the PDC so I imagine that it's ok.

I have heard from some beta testers that they received a e-mail from MS
releasing them from their NDA's, so I guess the cat is offically out of the
bag.
 
I personaly can live with out that... Never used 'em in VB.CLASSIC, so
I don't expect to now :) But, it will make a lot of other peoples lives
easier.

This doesn't work exactly like VB classic. You have to use the new "My"
object: My.Forms.Form1.Show
Wooo! Hoooo! Especially the unsigned types and generics.


Oh, and I forgot to mention Edit and Continue and XML documentation.
 
Hi Chris,
4. IsNot keyword. Now instead of If Not someObj Is Nothing, you can
write If someObj IsNot Nothing

This looks greath to me

If Not someObj IsNot Nothing

:-)) I hope they skip it before it comes actual

It has in my opinion to be (came out some arguing between Jay B and me)

If someObj Is Something

Cor
 
This doesn't work exactly like VB classic. You have to use the new "My"
object: My.Forms.Form1.Show



Oh, and I forgot to mention Edit and Continue and XML documentation.

<spit>E&C</spit> I don't need no stinking E&C... I really don't mind
if they include it... I just will probably never use it. I never used
it when we did have it :)

XML docs are good, but I think over rated.
 
Chris,
This doesn't work exactly like VB classic. You have to use the new "My"
object: My.Forms.Form1.Show
And it appears to be controlled by an attribute, and the Singleton Pattern.

Tell Whidbey to show attributes and check out the designer generated code.

Hope this helps
Jay
 
Chris,
Don't forget the Using statement, if you use Dispose as you are suppose to
Using is going to be a life saver (well a typing saver)!

The one caution I would like to remind every one about. The PDC bits are
Technology Preview (read a pre alpha & pre beta).

Which means that during subsequent betas that "names & faces" may change. As
a recent thread suggests. Originally in VB.NET 1.0 alpha there were BitAnd &
BitOr operators, which were dropped in favor of the original And & Or
operators & the AndAlso & OrElse operators for the Beta 2 release.

So although we see a IsNot (Woo Hoo!!!!) it may (or may not) be changed in a
subsequent beta.

I just wish I knew where more info on the Generics in VB.NET is. The only
real document I know about is the "Sample Chapter on Generics" at
http://msdn.microsoft.com/vbasic/whidbey/ which is the same document on the
PDC DVD, however it is not enough. More Input! More Input! Luckily I know
C++ templates & have lots of C# samples, so some of it I have 'figured' out.

Oh! This blog is good for the new VB.NET features
http://blogs.gotdotnet.com/cambecc/ He currently covers Operator Overloading
& Unsigned Types.

Hope this helps
Jay
 
Cor,
If Not someObj IsNot Nothing
:-)) I hope they skip it before it comes actual

I hope you realise most people will normally use:

If someObject IsNot Nothing Then
someObject.DoSomething()
End If

Rather then:

If Not someObject IsNot Nothing Then
' This space intentionally left blank
Else
someObject.DoSomething()
End If

I am curious if Not IsNot will cause an error...
It has in my opinion to be (came out some arguing between Jay B and me)
I didn't think we were arguing ;-)

I prefer:
If someObj Is Something

As its more "positive", however IsNot also works, so I'm happy ;-)

Hope this helps
Jay
 
Jay,
I just wish I knew where more info on the Generics in VB.NET is. The only
real document I know about is the "Sample Chapter on Generics" at
http://msdn.microsoft.com/vbasic/whidbey/ which is the same document on the
PDC DVD, however it is not enough. More Input! More Input! Luckily I know
C++ templates & have lots of C# samples, so some of it I have 'figured' out.

Any particular piece of information you think is missing?



Mattias
 
Mattias,
Any particular piece of information you think is missing?

The proper syntax! ;-) I don't think there is a piece missing per se,
because of the preview-ness of Whidbey the VB.NET syntax is not fully
documented... (as the MSDN article says the C# syntax is "stabilized"
already for generics.
http://msdn.microsoft.com/msdnmag/issues/03/09/NET/default.aspx)

For example in C# I can use the constructor constraint:

class MyFactory<T,P> where T : new()

How do I say that in VB.NET?

In C# I can list more then one interface or base class on the interface &
base class constraints.

class Node<T> where T : IComparable, IFormatable

I figured out you use & in VB.NET:

Class Node(Of T As IComparable & IFormatable)

However I do not see "&" documented. :-)

How do I implement a generic interface such as
System.Collections.Generics.IList(of T)?

I have something that compiles, however it does not run. Of course this is a
preview version of the compiler and I may be asking too much of it at this
time ;-)

Thanks for any links!
Jay
 
Jay,
For example in C# I can use the constructor constraint:

class MyFactory<T,P> where T : new()

How do I say that in VB.NET?

In C# I can list more then one interface or base class on the interface &
base class constraints.

class Node<T> where T : IComparable, IFormatable

I figured out you use & in VB.NET:

Class Node(Of T As IComparable & IFormatable)

However I do not see "&" documented. :-)

The & syntax is gone, fortunately. Many alternatives were discussed,
and the current constraint syntax is

Class MyGen(Of S As Foo, T As {Bar, Baz})

(wohoo, more curlies! ;-) I hope I got that right, I'm typing from
memory here. It was covered in the MSDN chat two days ago.

The New constraint should be supported eventually as well, but I don't
think it is in the PDC bits.

How do I implement a generic interface such as
System.Collections.Generics.IList(of T)?

Just the way you'd expect to

Class Foo
Implements IList(Of String)

Sub Clear() Implements IList(Of String).Clear
...
End Class

I have something that compiles, however it does not run.

In what way does it fail to run?

Of course this is a
preview version of the compiler and I may be asking too much of it at this
time ;-)

Yeah, there's much left to be implemented.



Mattias
 
Mattias,
I get a "Fatal Execution Engine Error"
The & syntax is gone, fortunately. Many alternatives were discussed,
and the current constraint syntax is

Class MyGen(Of S As Foo, T As {Bar, Baz})
See something changed already (referring to my earlier caution) ;-)

Curlies make sense & regular parentheses make sense... I was thinking And
instead of &.
Class Foo
Implements IList(Of String)

Sub Clear() Implements IList(Of String).Clear
...
End Class
Yes I got the above to work, however I was playing with defining a Generic
Type.

Class Foo(Of ItemType)
Implements IList(Of ItemType)

Sub Clear() Implements IList(Of ItemType).Clear

End Class

The above gives me an error about "Type argument 'ItemType' does not inherit
from or implement 'System.Object'", when "obviously" it does as its a Type
in .NET. If I give 'ItemType As Object' or other class it then compiles
however I then get the "Fatal Execution Engine Error", which is where I
think the preview still has a couple of rough edges ;-)

I think I may step back, and try implementing a simply generic interface in
my generic class.

Thanks
Jay
 
Back
Top