편집

다음을 통해 공유


Type-declaration character not allowed

While using type-declaration characters is valid in Visual Basic, some data types (including Byte, Boolean, Date, Object, and Variant) have no associated type-declaration characters. This error has the following causes and solutions:

  • You tried to use a type-declaration character in the declaration of a variable that uses the As clause, for example, with Dim, Static, Public, and so on.

    Either remove the type-declaration character or remove the As clause.

  • You tried to use a type-declaration character in reference to a variable that was implicitly declared without a type-declaration character:

        MyVar = 20    ' Implicit declaration. 
        MyVar% = 25   ' Generates an error. 
    
      Dim MyStr$  
      MyStr = "Because it was explicitly declared, the $ is optional." 
    

    Either remove the type-declaration character or redeclare the original variable.

    Note

    If an explicit variable declaration contains a type-declaration character, inclusion of the character is optional in later references.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.