|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
New obj() vs. New objI am interested in discerning the difference from my textbook and the actual behavior of the MS Dev IDE 2003. My textbook specifies: objOleDbCommand = New OleDbCommand() I type that in the VB Editor. However when I end the line and start typing the next code line, the editor automatically removes the closing parentheses () from end of the line so that it leaves this: objOleDbCommand = New OleDbCommand Any idea why this is? I wonder if this is something new in the MS Dev Environment for version 2003. Any time I put an arg in the the parens, then the IDE does not delete them. Thanks, Erik In VB.NET when instantiating a new object via its parameterless constructor
does not need the empty parethesis "()". However, using a constructor with parameter does require them. It's an IDE feature to remove them. I don't know the reason for that, but they mean the same thing. Show quoteHide quote "Erik" wrote: > Hi all, > > I am interested in discerning the difference from my textbook and the > actual behavior of the MS Dev IDE 2003. > > My textbook specifies: > > objOleDbCommand = New OleDbCommand() > > I type that in the VB Editor. However when I end the line and start > typing the next code line, the editor automatically removes the closing > parentheses () from end of the line so that it leaves this: > > objOleDbCommand = New OleDbCommand > > Any idea why this is? I wonder if this is something new in the MS Dev > Environment for version 2003. > > Any time I put an arg in the the parens, then the IDE does not delete > them. > > Thanks, > Erik > > "rmacias" <rmacias@newsgroup.nospam> schrieb: The intention for automatically removing the '()' on constructor calls was > In VB.NET when instantiating a new object via its parameterless > constructor > does not need the empty parethesis "()". However, using a constructor > with > parameter does require them. > > It's an IDE feature to remove them. I don't know the reason for that, but > they mean the same thing. to visually disambiguish constructor calls from array declarations: \\\ Dim a As New Object() {} Dim b As New Object /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Ahhhhh......that make total sense now.
Show quoteHide quote "Herfried K. Wagner [MVP]" wrote: > "rmacias" <rmacias@newsgroup.nospam> schrieb: > > In VB.NET when instantiating a new object via its parameterless > > constructor > > does not need the empty parethesis "()". However, using a constructor > > with > > parameter does require them. > > > > It's an IDE feature to remove them. I don't know the reason for that, but > > they mean the same thing. > > The intention for automatically removing the '()' on constructor calls was > to visually disambiguish constructor calls from array declarations: > > \\\ > Dim a As New Object() {} > Dim b As New Object > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > >
Show quote
Hide quote
> Hi all, I don't have a copy with me to test, but I believe either the 2002 version > > I am interested in discerning the difference from my textbook and the > actual behavior of the MS Dev IDE 2003. > > My textbook specifies: > > objOleDbCommand = New OleDbCommand() > > I type that in the VB Editor. However when I end the line and start > typing the next code line, the editor automatically removes the > closing parentheses () from end of the line so that it leaves this: > > objOleDbCommand = New OleDbCommand > > Any idea why this is? I wonder if this is something new in the MS Dev > Environment for version 2003. > > Any time I put an arg in the the parens, then the IDE does not delete > them. or one of it's beta versions required the (). Most likely the textbook was written with one of these early versions and not updated when the more recent versions were released. The reason for removing the () from the constructor is to dis-ambiguate the type from the array version of the type. Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx Thanks to all of you for the very sensible explanations!
Erik. Jim Wooley wrote: Show quoteHide quote > > Hi all, > > > > I am interested in discerning the difference from my textbook and the > > actual behavior of the MS Dev IDE 2003. > > > > My textbook specifies: > > > > objOleDbCommand = New OleDbCommand() > > > > I type that in the VB Editor. However when I end the line and start > > typing the next code line, the editor automatically removes the > > closing parentheses () from end of the line so that it leaves this: > > > > objOleDbCommand = New OleDbCommand > > > > Any idea why this is? I wonder if this is something new in the MS Dev > > Environment for version 2003. > > > > Any time I put an arg in the the parens, then the IDE does not delete > > them. > > I don't have a copy with me to test, but I believe either the 2002 version > or one of it's beta versions required the (). Most likely the textbook was > written with one of these early versions and not updated when the more recent > versions were released. The reason for removing the () from the constructor > is to dis-ambiguate the type from the array version of the type. > > Jim Wooley > http://devauthority.com/blogs/jwooley/default.aspx
App already running?
Any way to allow F1 help for menu items in VB.NET? Installation monitoring and capture...... Calling forms from a Form years,months,days transparent labels on pictureboxes "Key not found" Exception Assigning to DataSource Property of Grid Unhandled exceptions in Vs 2005 Is Visual Studio Installer available with Visual Basic 2005 Expres aspnet vb webproject |
|||||||||||||||||||||||