Home All Groups Group Topic Archive Search About
Author
29 Mar 2005 3:01 PM
Bruce D
I've just begun to write my third VB.NET program and I thought I should ask
the simple question...

Should I be using me.txtname.text or txtname.text?  Most of my programs are
using the ME. prefix when referring to the objects on a form.  I know it's
the same thing.  I find it easier to read using "me." but I want my code to
be as efficient as possible.  I did a quick Google, but found nothing.  Are
there performance issues or is it only a preference?

Just wanted the groups $.02

-bruce duncan

Author
29 Mar 2005 3:19 PM
Supra
doesn't matter.
me.txtname.text or txtname.text both r same

Bruce D wrote:

Show quoteHide quote
>I've just begun to write my third VB.NET program and I thought I should ask
>the simple question...
>
>Should I be using me.txtname.text or txtname.text?  Most of my programs are
>using the ME. prefix when referring to the objects on a form.  I know it's
>the same thing.  I find it easier to read using "me." but I want my code to
>be as efficient as possible.  I did a quick Google, but found nothing.  Are
>there performance issues or is it only a preference?
>
>Just wanted the groups $.02
>
>-bruce duncan
>
>

>
Author
29 Mar 2005 3:29 PM
Alejandro Lapeyre
One difference is that you dont have to type the full name if you start with
Me.

Best Regards,
Alejandro Lapeyre

Show quoteHide quote
"Supra" <supr***@rogers.com> escribió en el mensaje
news:OC6cjKHNFHA.4052@TK2MSFTNGP12.phx.gbl...
> doesn't matter.
> me.txtname.text or txtname.text both r same
>
> Bruce D wrote:
>
>>I've just begun to write my third VB.NET program and I thought I should
>>ask
>>the simple question...
>>
>>Should I be using me.txtname.text or txtname.text?  Most of my programs
>>are
>>using the ME. prefix when referring to the objects on a form.  I know it's
>>the same thing.  I find it easier to read using "me." but I want my code
>>to
>>be as efficient as possible.  I did a quick Google, but found nothing.
>>Are
>>there performance issues or is it only a preference?
>>
>>Just wanted the groups $.02
>>
>>-bruce duncan
>>
>>
>>
>
Author
29 Mar 2005 3:40 PM
Qwert
Think that both syntax is compiled to the same result.

It can happen that you have 2 variables with the same name but different
scope:
strTest = member variable of class.
strTest = local variable of function in that class.
Inside that function, 'Me.strTest' is not 'strTest'. In this case, if you
force yourself to always use 'me', you wont make a mistake here.
Obviously it's best to prevent multiple variables with same name.

I can imagine that some programmers prefer code to be as short as possible,
and leave out 'me'.


Show quoteHide quote
> I've just begun to write my third VB.NET program and I thought I should
> ask
> the simple question...
>
> Should I be using me.txtname.text or txtname.text?  Most of my programs
> are
> using the ME. prefix when referring to the objects on a form.  I know it's
> the same thing.  I find it easier to read using "me." but I want my code
> to
> be as efficient as possible.  I did a quick Google, but found nothing.
> Are
> there performance issues or is it only a preference?
>
> Just wanted the groups $.02
>
> -bruce duncan
>
>
Author
29 Mar 2005 5:40 PM
M. Posseth
The auto generated code uses Me  , and i myself think it is verry handy (
saves me some typing ) i can`t  think of a reasson not to use it


Show quoteHide quote
"Bruce D" <brucexwxdunc***@hotmail.com> wrote in message
news:114ire4f23egg78@corp.supernews.com...
> I've just begun to write my third VB.NET program and I thought I should
ask
> the simple question...
>
> Should I be using me.txtname.text or txtname.text?  Most of my programs
are
> using the ME. prefix when referring to the objects on a form.  I know it's
> the same thing.  I find it easier to read using "me." but I want my code
to
> be as efficient as possible.  I did a quick Google, but found nothing.
Are
> there performance issues or is it only a preference?
>
> Just wanted the groups $.02
>
> -bruce duncan
>
>
Author
29 Mar 2005 7:23 PM
Herfried K. Wagner [MVP]
"Bruce D" <brucexwxdunc***@hotmail.com> schrieb:
> I've just begun to write my third VB.NET program and I thought I should
> ask
> the simple question...
>
> Should I be using me.txtname.text or txtname.text?  Most of my programs
> are
> using the ME. prefix when referring to the objects on a form.  I know it's
> the same thing.  I find it easier to read using "me." but I want my code
> to
> be as efficient as possible.  I did a quick Google, but found nothing.
> Are
> there performance issues or is it only a preference?

There is no performance difference between specifying 'Me' or omitting it.
However, sometimes 'Me' will be required to resolve a name clash.  I always
use 'Me' because it gives me easy access to the form's members in
IntelliSense and helps me to write code in less time :-).

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>