Solved

Coding Standards

Posted on 1997-03-10
5
407 Views
Last Modified: 2008-03-06
Where can I obtain a document containing a good coding standard for VB 4.0 ??
0
Comment
Question by:corelio
5 Comments
 

Expert Comment

by:JoeyH
ID: 1424258
Throughout the 'Language Reference' and 'Professional Features' manuals for VB 4.x you will find various examples of code naming standards. Also, the TechNet provides a document with coding standards, regarding naming conventions. If you do not have access to this, let me know and I will e-mail you a copy of it.

Regarding coding 'standards' insofar as style, etc., this is still a bit grey. Visual Basic provides the foundation tools for developing in the event-driven paradigm. What comes into play here the most is how to write code that can handle more than just a specific item, if/when applicable. For example, in a data entry form, you may want the application to behave such that each time the user cursors, or clicks within a text box, if there is already data in that box, automatically select those data. This follows Windows programming conventions. To do this, you would write code for the gotfocus event that selected the text automatically, like the following:

Sub obj_GotFocus()
   ' if text exist, select it...
   if len(txtObject) <> 0 then
      txtObject.SelStart = 0
      txtOBject.SelLength = len(txtObject)
   end if
End Sub

Doing this for each applicable text object would be tedious and a lot of code. Another approach would be:

within a public module (this is not a class approach)

Sub SelectField(lobjText as Control)
   ' If the control passed is Text, then if it contains data, select
   ' those data...
   If TypeOf Control Is Text Then
      If Len(lobjText) <> 0 Then
         lobjText.SelStart = 0
         lobjText.SelLength = Len(lobjText)
      End If
   End If
End Sub

Now, for the gotfocus event

Sub obj_GotFocus()
   ' Pass to our select field so any text will be selected...
   SelectField Screen.ActiveControl
End Sub


This is just a small example of coding with an approach that reduces 1) maintenance issues, 2) overall coding effort involved.

Try to design the application, using object/control names (possibly control arrays) with this mind-set.

I hope this has been helpful.

Have a nice day...
0
 

Author Comment

by:corelio
ID: 1424259
No ofenses, JoeyH´s , but I´m  very worried about maintanance of the code that our team writes in VB. So, I would like a FORMAL
document that specify a coding standard to be followed for
a large group of people programming in VB.

I´ve read the technical references and other Microsoft´s materials, but they are a pretty vague. And the other material
you quoted regards just naming conventions, right ??? I was
looking a document that describes many other details of coding
standard, like headers, syntax of VB comands, comments, and so
on, as described in the Personal Software Process book, of
Humphrey Watts. -> (Enginner Software Guru)

As I found a document very close to the format I want, I would like to share it with you and the other experts. It can be found at http:/www.apexsc.com/vb/ and has the name codstds.zip. It has
27 pages of description regarding these and other features.


Well, thanks a lot for you help, anyway.
See you
0
 

Expert Comment

by:JoeyH
ID: 1424260
As you have likely found by now, Microsoft does not publish much regarding a standard of design and coding. Though they do teach a fundamental layout, as you indicated, it is, as you say, vague. Actually, it's rather elementary.

You will find a number of articles on Carl and Gary's site that may suite what you are looking for. I am gathering that you are looking for something that will suite a corporate standard, based on your reply.

Microsoft publishes two training objects pertaining to programming prose, one more focused on VB 3 and the event driven paradigm, and one of OOP. Both are available through the Microsoft Press and can be queried on 'Programming Standards' through their ISBN library.

I sincerely apologize for not being of more help and wish you luck with the MS Press queries.

Have a nice day...
0
 

Expert Comment

by:Mabry
ID: 1424261
Have you looked at this document?

http://www.microsoft.com/kb/articles/q110/2/64.htm
0
 
LVL 3

Accepted Solution

by:
mheacock earned 50 total points
ID: 1424262
Send me your e-mail address and I'll send you a document for
coding standards I created for my job.  My e-mail is
   cerebus@islandnet.com
You can grade my answer based on the document when you
receive and review it.  It covers Delphi, C++, and VB.

The document is in Word 6.0 format.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question