PRB: Problems Editing Long Declares in the Conditional Compile

Last reviewed: February 22, 1996
Article ID: Q143403
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 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 INFORMATION

Steps to Reproduce the Problem

  1. Start Visual Basic. Form1 is created by default.

  2. 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
    
    

  3. Copy the Declare statement in the "If Win32" clause and paste it in the #Else clause.

  4. Insert the cursor following the "A" in "ShellExecuteA" and backspace over the "A".

  5. Commit the line by stepping off the declare statement.

  6. 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 reference words: vb4win vb4all 4.00
KBCategory: kbprg kbinterop
KBSubcategory: aprgother


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 22, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.