Some best practices which one should always follow while coding in Visual Basic. These practices will allow smooth programming and prevent intensive debugging.
  • Avoid ‘magic numbers‘ when you can. Use constants instead.
  • Be modular.
  • Defensively program.
  • Ideally, VB procedures should have only one purpose.
  • Deep nesting of loops should be avoided.
  • To protect sensitive data use access procedures.
  • The variables should always be defined with the smallest scope possible.
  • Don’t pass global variables to procedures.
  • Use “&” operator when linking strings and the “+” operator when working with numerical values.
  • While creating long string, underscore “_” line continuation character should be used to create multiple lines of code.
  • Variants should be avoided if possible.
  • As per Microsoft’s recommendation, code should be indented with four spaces.
  • Finally, watch out for mis-spelled variables.

Enjoy good programming in Visual Basic.

Suggested Posts…