473,378 Members | 1,319 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,378 software developers and data experts.

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 1693
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 ApplicationException("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*******@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.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*******@discussions.microsoft.com> schreef in bericht
news:0D**********************************@microsof t.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*******@discussions.microsoft.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*******@discussions.microsoft.com> wrote in message
news:FC**********************************@microsof t.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
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...
7
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...
1
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...
11
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...
23
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...
1
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...
5
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. ...
6
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...
6
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.