Guidelines for Entering and Editing Code

See AlsoTWXB4L

You enter and edit code in the Code windowJ73QNY.  The Code window has automatic formattingGJX4KK and syntax checkingHEOK7V capabilities built in.  If the syntax checker is turned on, Visual Basic displays a message when you enter code that has a syntax error.

Using the Code Window

         To enter code, click the Code window and start typing.

         To correct mistakes as you type, press Backspace.

         To delete text, select it and press Del.

         To move the insertion point0KIN01C, click where you want the insertion point to be, or use the Arrow keys.

         To indent text, select the line or lines you want to indent, and press Tab.  To remove an indent, press Shift+Tab.

         To switch between insert mode and overtype mode, press Ins.

         To enter a comment7P2T01P in your code, start the comment with an apostrophe ( ' ).

         To complete a Visual Basic statementKI4GSX, press Enter at the end of the line or move the pointer off the line.

         To write multiple statements on one line, use a colon (:) as a separator.  For example:  For I = 1 to 100: A(I) = I: Next I

         To view two procedures85Q5YR at a time, split the window by moving the split bar799NT7 down the side of the Code window.

         To accept argumentsDEFARG in a procedure, separate the arguments by commas if there is more than one, and enclose all the arguments in parentheses following the name of the procedure.  For example, Sub IncrementXY(X, Y).

         To pass argumentsDEFARG to a procedure, separate the arguments by commas if there is more than one, following the name of the procedure being called.  For example, IncrementXY X, Y.  Enclose the arguments in parentheses following the procedure name only if the the Call keyword is being used before the procedure name.  For example, Call IncrementXY(X, Y).

         To get Help on syntax for Visual Basic functions, statements, properties3MRB2KQ, events1L2S0SZ, or methods1XB6QBF while working in the Code window, type or select the keyword, the property, event, or method name, and press F1.


Declarations and Variables

         To make an assignment of one variable to another, use the syntax destination = source.

         To name a variableBIXX5W6, begin the name with a letter and use no more than 40 letters and numbers.

See Also


Attaching an Event Procedure to a Form or Control2LBGK4C

Creating a General Procedure1IPNOPP

Data Types2M0APUD

Entering Declarations in Code1AS3HT9


Programmer's Guide:

Chapter 2, "Your First Visual Basic Application"

Chapter 6, "Programming Fundamentals"

Chapter 7, "Variables, Constants, and Data Types"