Microsoft KB Archive/143403

= PRB: Problems Editing Long Declares in the Conditional Compile =

Article ID: 143403

Article Last Modified on 5/7/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Control Creation Edition
 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q143403



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.



Steps 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                       </li></ol>

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

Keywords: kbprb KB143403

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.