TIPS FOR NOVICES

A really nice feature of VB is when you move the cursor off a line, the syntax of the statement is checked and all the keywords and previously defined words turn to mixed case. (Mixed case is when the first letter of a word is in uppercase, while the remaining letters are in lower case e.g. Sub or DoThis)

This verifies whether your typing is correct or not.

If the keyword doesn't turn to mixed case, then you know its a typo.

Making user defined names mixed case makes sense, as you can detect typos of your user defined names.

Most of the time you can just type in lower case.


Other things happen the cursor moves off a line, including:

When a double-quote is needed at the end of a line, the editor will add it automatically, saving you needing to type it.

The editor places spaces around many symbols, including the +,-,/,* and = operators. (Note that spaces are not automatically placed around the & which is used to concatenate [join] strings.)

Sometimes spaces are placed between words. For example, endif expands to End If


After typing the name of an object, typing a dot invokes complete word, all the methods/properties of the object are displayed and you can select one.

After typing (or selecting) a method, pressing SPACE will display the argument list for that method. Optional arguments are within square brackets. Novices sometimes mistakenly add parenthesis around the arguments, they are not needed (even though they are displayed).


Most of the default option settings are usually adequate, but there are some you might like to change.

On the Environment tab, set "When a Program Starts" to "Save Changes". This will prevent you from losing your last edits if the system crashes.

If you select "Require Variable Declaration" on the Editor tab, any new projects subsequently opened, wil have the words "Option Explicit" at the top of each module. This will force you to create variables before you use them (usually with a Dim statement) and prevent bugs caused by typos.

Its useful to turn Syntax Checking off. Syntax errors will still be displayed in red, but the messagebox will not keep appearing.

The Run with Full Compile menu, doesn't compile your project (Make ProjectName.exe from the File menu does that), but checks all your code for syntax errors, rather than waiting to get to the line (or procedure) where the error is.

This can be quite useful for finding any syntax errors which might be "lying in wait".


Rename your controls using a 3 letter prefix which describes the type of control eg,
  1. cmd - commandbutton
  2. lbl - label
  3. txt - textbox
  4. lst - listbox
  5. cmb - combobox etc.
For example, a button with the capton "OK" could be called cmdOk.

Design your form and rename controls BEFORE writing code for your form. Otherwise you will need to rename your related event procedures.


The Alignment property for textboxes is ineffective unless the multiline property is set to true.


Empty procedures are deleted if they have no code in them. A single ' is sufficient to prevent this. eg. Sub Skeleton()
'
End Sub



If you have a tip you would like to add, just fill in the form.

Real name:

Email   adr:

What is your tip?



Back to basic page