Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/173571

From BetaArchive Wiki

Article ID: 173571

Article Last Modified on 5/13/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



This article was previously published under Q173571

SYMPTOMS

The following code (created by Visual Basic using the OUTLOOK.MAILITEM object) is displayed in the color red by the Visual Basic IDE, indicating an error in the code:

   Private Sub MailItem_SaveAs(ByVal Path As String,_
         Optional ByVal Type As Variant)
                

CAUSE

The code generated uses "Type" in the second argument. "Type" is a reserved word in Visual Basic.

RESOLUTION

Rename the second argument from "Type" to something that is not a reserved word in this declaration:

   Private Sub MailItem_SaveAs(ByVal Path As String,_
        Optional ByVal Type As Variant)
                

Replace "Type" with "Arg2" as follows:

   Private Sub MailItem_SaveAs(ByVal Path As String,_
        Optional ByVal Arg2 As Variant)
                

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start Visual Basic or, if Visual Basic is already running, choose New Project.
  2. Select Project from the menu, and then select the References item. Choose the Microsoft Outlook 8.0 object module.
  3. Add a class module named Class1, and then add the following code:

          IMPLEMENTS OUTLOOK.MAILITEM
                            
  4. Select "MailItem" from the Object drop-down box, and then select "SaveAs" from Procedures/Events drop-down box. The following code gets inserted in the code window:

          Private Sub MailItem_SaveAs(ByVal Path As String,_
            Optional ByVal Type As Variant)
    
          End Sub
                            
  5. Note that the second argument is "Type," which is a reserved word in Visual Basic.
  6. Save the project as Project1.
  7. Close the project.
  8. Open Project1 and view your code in Class and note that the code looks like the following in the editor:

          'This line is in red >>>   Private Sub MailItem_SaveAs(ByVal Path As
          String, Optional ByVal Type As Variant)
    
          'This line is in black>>>   End Sub
                            

The line in red means there is an error in this line of code, specifically on the name "Type."


Additional query words: kbVBp500bug kbVBp600bug kbVBp kbdse kbDSupport

Keywords: kbbug KB173571