Solved

Coding Standards

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now