PRB: Code Copied From MSDN VStudio Help Is Improperly Formatted

ID: Q190266


The information in this article applies to:


SYMPTOMS

When you copy code examples from the MSDN Library Visual Studio 6.0 Help Viewer, it omits some carriage return/line feed characters and the code is not formatted correctly.


CAUSE

Formatting tags are included at the start and end of each example, and the code is not be formatted properly if you do not copy these tags.


RESOLUTION

When copying code, be sure to completely include the first and last lines of the code example.


STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


MORE INFORMATION

The documentation for Visual Studio 6.0 is accessed from a common viewer called MSDN Library Visual Studio 6.0 Help Viewer. All Visual Studio 6.0 products that have code examples are affected by this problem. These include, but may not be limited to, Visual FoxPro 6.0, Visual Basic 6.0, Visual C++ 6.0 and Visual J++ 6.0.

Steps to Reproduce Behavior

Using Visual FoxPro:
  1. In Visual FoxPro, type the following in the Command Window and press enter:


  2. help DATE()
  3. In the DATE() Function topic page, click the Example hyperlink.


  4. Using your mouse, select any multiple-line portion of the code in the example that excludes either the first or last lines of the code, or both.


  5. Press Ctrl+C to copy the highlighted code.


  6. Paste the code into an edit window in Visual FoxPro, or into another application such as Notepad.


RESULT: Some of the line feeds are omitted. Using the DATE() Function example, if you copy the second, third, and fourth lines the code is formatted as follows:

   SET CENTURY OFF? DATE( )  && Displays today's date without the century.
   SET CENTURY ON 

The correct formatting is:

   SET CENTURY OFF
   ? DATE( )  && Displays today's date without the century.
   SET CENTURY ON 

If you copy the entire code example, including the entire first and last lines, the code is formatted as follows:

   CLEAR
   SET CENTURY OFF
   ? DATE( )  && Displays today's date without the century.
   SET CENTURY ON
   ? DATE( )  && Displays today's date with the century.
   ? DATE(1998, 02, 16)  && Displays a year 2000-compliant Date value. 

Using Visual Basic:
  1. In Visual Basic Help, find the ActiveControl Property topic.


  2. In the ActiveControl Property topic, click the Example hyperlink.


  3. Using your mouse, select any multiple-line portion of the code in the example that excludes either the first or last lines of the code, or both.


  4. Press Ctrl+C to copy the highlighted code.


  5. Paste the code into the Code Window in Visual Basic, or into another application such as Notepad.


RESULT: Some of the line feeds are omitted. Using the ActiveControl Property example, if you copy the second through the sixth lines the code is formatted as follows:

   If TypeOf Screen.ActiveControl Is TextBox Then
      Label1.Caption = Screen.ActiveControl.Text   Else
      Label1.Caption = "Button: " + Screen.ActiveControl.Caption   End If 

The correct formatting is:

   If TypeOf Screen.ActiveControl Is TextBox Then
      Label1.Caption = Screen.ActiveControl.Text
   Else
      Label1.Caption = "Button: " + Screen.ActiveControl.Caption
   End If 

If you copy the entire code example, including the entire first and last lines, the code is formatted as follows:

   Private Sub Form_Click ()
      If TypeOf Screen.ActiveControl Is TextBox Then
         Label1.Caption = Screen.ActiveControl.Text
      Else
         Label1.Caption = "Button: " + Screen.ActiveControl.Caption
      End If
   End Sub 

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Jim Saunders, Microsoft Corporation

Additional query words:


Keywords          : kbVBp600 kbVC600 kbVFp600 kbVJ600 kbVS600 
Version           : WINDOWS:6.0; winnt:6.0
Platform          : WINDOWS winnt 
Issue type        : kbprb 

Last Reviewed: April 14, 1999