Error Using Call Statement with Function Procedure

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 :
Version : :1.0
Platform : WINDOWS
Issue type :


Last Reviewed: October 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.