Solved

Coding Standards

Posted on 1997-03-10
5
409 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

829 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