473,667 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Common VB nomenclature

I've noticed a nomenclature used by many VB developers of preceding variable
names by an underscore e.g. _instance.

Under what context is this usually used/not used.

Thanks.
May 29 '06 #1
7 1713
SparkPlug,

This naming convention is used by some VB programmers when naming the
private variable that "backs" a public property procedure. For example:

Private _Test1 As Single

Public Property Test1() As Single
Get
Return _Test1
End Get
Set(ByVal Value As Single)
If Value >= 0 And Value <= 100 Then
_Test1 = Value
Else
Throw New ApplicationExce ption("Invalid Test1 value")
End If
End Set
End Property

Kerry Moorman

"SparkPlug" wrote:
I've noticed a nomenclature used by many VB developers of preceding variable
names by an underscore e.g. _instance.

Under what context is this usually used/not used.

Thanks.

May 29 '06 #2
SparkPlug,
As Kerry suggests it common to use _instance for instance fields.

Especially on Properties as you cannot have a Property named Instance & a
field called instance as you can in C#.

As a matter of consistency I generally prefix *all* fields m_ as I see no
value in identifying fields that back properties as opposed to other fields
that may be on a class. I simply see them as fields on a class...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"SparkPlug" <Sp*******@disc ussions.microso ft.com> wrote in message
news:0D******** *************** ***********@mic rosoft.com...
| I've noticed a nomenclature used by many VB developers of preceding
variable
| names by an underscore e.g. _instance.
|
| Under what context is this usually used/not used.
|
| Thanks.
May 29 '06 #3
SparkPlug,

As any underscore in a program, I hate them. Some cursors hide those
underscore.

I use as I have seen more done for a private field accessed by a property a
single m as prefix.

And in my idea is that the only place that I need them.

Cor

"SparkPlug" <Sp*******@disc ussions.microso ft.com> schreef in bericht
news:0D******** *************** ***********@mic rosoft.com...
I've noticed a nomenclature used by many VB developers of preceding
variable
names by an underscore e.g. _instance.

Under what context is this usually used/not used.

Thanks.

May 29 '06 #4
Thanks to all replies.

It is as I suspected so I was using it in that way but had never actually
been informed for certain.

May 29 '06 #5
"SparkPlug" <Sp*******@disc ussions.microso ft.com> schrieb:
I've noticed a nomenclature used by many VB developers of preceding
variable
names by an underscore e.g. _instance.

The naming guidelines do not have any information on how to name private
variables. However, some people use the '_' or 'm_' prefix to visually mark
them as private variables:

\\\
Private m_UserName As String

Public Property UserName() As String
Get
Return m_UserName
End Get
Set(ByVal Value As String)
m_UserName = Value
End Set
End Property
///

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

May 29 '06 #6


"Jay B. Harlow [MVP - Outlook]" wrote:

As a matter of consistency I generally prefix *all* fields m_ as I see no
value in identifying fields that back properties as opposed to other fields
that may be on a class. I simply see them as fields on a class...


Just curious, where did the 'm' come from?
Thanks.

May 29 '06 #7
SparkPlug
| Just curious, where did the 'm' come from?
I learned it in C++ it stands for Member.

Some VB6 developers use it to stand for Module...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"SparkPlug" <Sp*******@disc ussions.microso ft.com> wrote in message
news:FC******** *************** ***********@mic rosoft.com...
|
|
| "Jay B. Harlow [MVP - Outlook]" wrote:
| >
| > As a matter of consistency I generally prefix *all* fields m_ as I see
no
| > value in identifying fields that back properties as opposed to other
fields
| > that may be on a class. I simply see them as fields on a class...
|
| Just curious, where did the 'm' come from?
| Thanks.
|
May 29 '06 #8

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

Similar topics

3
6788
by: S.W. Rasmussen | last post by:
With the risk of being accused of multi-posting I would like to draw the attention to a serious visual basic/windows issue discussed in the microsoft.public.vb.bugs newsgroup. As pointed out below by Norman Diamond the bug may result in loss of data when saving files with the standard common dialog control. Norman Diamond describes the problem as follows: ---------- In VB6 SP6, VB6 SP5, and possibly others, the common dialog box...
7
5066
by: Sherry Littletree | last post by:
Hi All I am working on a site that has a large amount of common html on all its web pages. I am looking for a way to place this in a single file so, if changes are made, I can change this single file and do not have to change each and every page. I have the Java scripting in a common .Js file but have not been able to find a way to do this with my html content.
1
5001
by: Endif | last post by:
I am tring to execute the following SQL statements through the Iseries Navigator for DB2/V8.2, But i come up with an error saying recursion is not allowed in common table expression. This is a example i picked up from SQL cook book. I am not sure where i am wrong. Any help is appreciated WITH TEMP ( SUPV_ID,EMPID, FIRSTNAME) AS ( SELECT TV.SUPV_ID,TV.EMPID, TV.FIRSTNAME
11
2366
by: bill | last post by:
I recently worked with a piece of code where dereferencing the pointer was too slow, and I was able to achieve a nearly 2x speed-up by replacing a local array of size 8 with 8 local variables. (*x requires 2 fetches, x requires 1, so it's easy to explain it, I was just surprised that I actually encountered a situation where it makes sense to do this optimization.) Now, I want to test a similar situation, but the array that will be...
23
6990
by: George | last post by:
Is there a way to customize the open file common dialog? I am trying to modify the button text so I can create a delete file common dialog. I need the same functionality of the open file common dialog but just need to change the button text from "open" to "delete". Any ideas? Thanks
1
3379
by: bminder | last post by:
In the asp.net pages below, Common.vb has an overridable Page_Load sub. In the consuming page, Two.aspx, the Page_Load sub is inherited, but for some reason it (Overrides Sub Page_Load) executes twice. In another "regular" asp.net page that inherits only from its own codebehind page, the page load only executes once as you'd expect. Any ideas why the page_load fires twice in the former example? Thanks,
5
3189
by: wrecker | last post by:
Hi all, I have a few common methods that I need to use at different points in my web application. I'm wondering where the best place would be to put these? I think that I have three options. 1. I can create a common module like common.vb in my project and put all the functions in there. 2. Create a utility class and create the common functions as shared
6
1737
by: Peter | last post by:
Hi I have a number of arrays of longs, from which I need to find a single array which only contains the values which appear in all the original arrays. For example, I could have the three arrays: 1, 3, 2, 8, 5 3, 6, 1
6
11479
Markus
by: Markus | last post by:
Things to discuss: Headers What are they? What does PHP have to do with headers? Why can they only be sent before any output? Common causes
0
8366
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.