Error Using Call Statement with Function Procedure

Last reviewed: July 29, 1997
Article ID: Q114696
The information in this article applies to:
  • Microsoft Visual Basic Programming System, Applications Edition, version 1.0

SYMPTOMS

In a Microsoft Visual Basic Programming System, Applications Edition, procedure, if you enter the Call statement followed by a Function procedure and the function name contains a type-declaration character, you receive the following error message:

   Expected: Identifier without type suffix or bracketed expression or .

If you clear the Display Syntax Errors check box on the Module General tab of the Options dialog box, or you ignore the above error message, you receive a syntax error when you run the procedure that contains this Call statement.

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.

CAUSE

This problem occurs because when you use the Call statement to call a Function procedure, the return value is discarded. If you call a Function procedure as you would call a Sub procedure, using the Call statement, the Function procedure name must follow the Sub procedure naming rules, and a

Sub procedure name cannot contain a type-declaration character.

WORKAROUND

To avoid receiving this error message, or a syntax error when you run a Function procedure, do either of the following:

  • Do not use a type-declaration character in your function name. Instead, use the As keyword with the Function statement to declare the function return value type. The following example defines the value returned by the Test function as string type:

          Function Test(x) as String
    

    -or-

  • Do not use the Call statement to run the function when the function name contains a type-declaration character.

MORE INFORMATION

A type-declaration character is a character that you can add to the end of a variable name to indicate the data type of the variable. For example, to declare a variable as string type, you can append the $ to the variable name as follows:

   Name$ = "Chris"

A function name can contain a type-declaration character; the function will run when you call the function using the function name. For example, to call the function Test$(), you can call the function in a procedure using the following syntax without receiving an error message:

   Test$

However, when you use the Call statement to run a function, you receive the above error message when you press ENTER at the end of the line that contains the Call statement if the function name contains a type- declaration character. For example, you receive the error message when you press ENTER at the end of the following line of code:

   Call Test$

REFERENCES

For a definition of the Type-Declaration Character, choose the Search button in the Visual Basic Reference and type:

   type-declaration character

For more information about the Call statement, choose the Search button in the Visual Basic Reference and type:

   call


Additional query words: errmsg err msg
Keywords : kbcode kberrmsg kbprg
Version : 1.00
Platform : WINDOWS


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: July 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.