PRB: Problems Editing Long Declares in the Conditional Compile
ID: Q143403
|
The information in this article applies to:
-
Microsoft Visual Basic Control Creation, Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
-
Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0
SYMPTOMS
When you have long declare statements in conditional code, if you copy the
declare from one condition to the other, then modify the identifier in the
Alias clause, additional changes occur in your declaration which you did
not specify.
CAUSE
This behavior is by design. The Alias clause disappears and the type
elements wrap differently; however, the code runs as desired.
MORE INFORMATIONSteps to Reproduce the Problem
- Create a new Standard EXE project in Visual Basic. Form1 is created by
default.
- Place the following code in the declaration section of Form1.
#If Win32 Then
Private Declare Function ShellExecute Lib _
"shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
#Else
#End If
- Copy the Declare statement in the "If Win32" clause and paste it in the
#Else clause.
- Insert the cursor following the "A" in "ShellExecuteA" and backspace
over the "A".
- Commit the line by stepping off the declare statement.
- The line continuation for the #ELSE clause gets scrambled as is shown
below. The Alias clause is gone and the type elements are not wrapped as
you would expect; however, the code runs as desired.
#If Win32 Then
Private Declare Function ShellExecute Lib _
"shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
#Else
Private Declare Function ShellExecute Lib _
"shell32.dll" (ByVal _
hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile _
As String, ByVal lpParameters _
As String, ByVal lpDirectory _
As String, ByVal nShowCmd _
As Long) As Long
#End If
If you press CTRL+Z to undo the erasing of the "A", the following will
appear. The actual edit is undone, but your incorrect line continuations
are still there. This code will not run because part of the declaration is
missing.
Private Declare Function ShellExecute Lib _
"shell32.dll" Alias "ShellExecuteA" _
hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile _
As String, ByVal lpParameters _
As String, ByVal lpDirectory _
As String, ByVal nShowCmd _
As Long) As Long
Additional query words:
Keywords : kbnokeyword kbVBp400 kbVBp500 kbVBp600 kbGrpVB
Version : WINDOWS:4.0,5.0,6.0
Platform : WINDOWS
Issue type : kbprb
|