473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

New obj() vs. New obj

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

Jun 5 '06 #1
5 1011
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.

"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

Jun 5 '06 #2
"rmacias" <rm*****@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/>

Jun 5 '06 #3
> 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
Jun 5 '06 #4
Ahhhhh......that make total sense now.

"Herfried K. Wagner [MVP]" wrote:
"rmacias" <rm*****@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/>

Jun 5 '06 #5
Thanks to all of you for the very sensible explanations!

Erik.

Jim Wooley 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.


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


Jun 8 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Steven C. | last post by:
When you compile a cpp program that includes a template class in a .h file where does the compiled code go for that templated class? If it went in the obj for the cpp program seems to me you could...
4
by: Akhil | last post by:
Hi All, Can u please explain this. Base Obj = new Derived(); Can Obj access methods both of Base and Derived or what will be the behaviour? What will be the behaviour for Overridden...
8
by: consultutah | last post by:
I am trying to upgrade from VS7.1 to VS8, but whenever I link any of our MC++ DLL's, I get the following errors: Creating library \sda\Main\bin\debug\XWRAP70.lib and object...
3
by: Mark Kamoski | last post by:
Hi-- What is the difference between Convert.ToString(obj) and CType(obj, String)? (Assume obj is a variable of type Object.) Please advise. Thank you.
1
by: sethuganesh | last post by:
HI, i have ported vc++ 6.0 code to visual studio 2005. During batch build in debug mode i din't get any error.But if i build the same in release mode i am getting the following error. ...
9
by: alf | last post by:
Hi, I have a reference to certain objects. What is the most pythonic way to test for valid reference: if obj: if None!=obs: if obj is not None:
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
3
by: john_owens | last post by:
I have a templated function called splitAndSegment (templated on the datatype). It's declared in a header file. I then include that header file in two separate cpp files and link them separately....
3
by: Eric Layman | last post by:
Hi, I have a script here which will loop thru a table and check for it's background color. But it doesn't work on Firefox. The Error Inspector said "ERROR. obj.cells has no properties How...
40
by: gert | last post by:
#include <stdio.h> obj function hello(){ struct obj = { char *data = 'hello'} obj.add = obj_add(obj); return obj; } void function obj_add(obj){ obj function add(value){
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.