DeleteLines Method
Applies To
CodeModule object.
Description
Deletes a single line or a specified range of lines.
Syntax
object.DeleteLines (startline [, count])
The DeleteLines syntax has these parts.
Part | Description |
|
object | Required. An object expression that evaluates to an object in the Applies To list. |
startline | Required. A Long specifying the first line you want to delete. |
count | Optional. A Long specifying the number of lines you want to delete. |
Remarks
If you don't specify how many lines you want to delete, the DeleteLines method deletes one line.
See Also
InsertLines method, Lines method.
Example
The following example has two steps. The first For…Next loop uses the InsertLines method to insert into CodePanes(1) 26 ever-longer initial segments of the alphabet, starting with "a". The last line inserted is the entire alphabet.
The second For…Next loop uses the DeleteLines method to delete the odd-numbered lines. Although it seems that the second loop should simply delete every other line, note that after each deletion the lines get renumbered. Therefore the deletion is advancing by two lines at each step, one line because I is increasing by one and another line because the larger line numbers are each decreasing by one.
For I = 1 to 26
Application.VBE.SelectedVBComponent.CodeModule.InsertLines i, _
Mid$("abcdefghijklmnopqrstuvwxyz", 1, I)
Next
For I = 1 to 13
Application.VBE.SelectedVBComponent.CodeModule.DeleteLines I
Next