首页 > 解决方案 > symbol expected in first line of libre office type definition

问题描述

Talk about a newbie! I can't get my first line to compile. Basic syntax error: Symbol expected

REM  *****  BASIC  *****
Type xyz
    Dim sheet as object
    Dim cell as object
    dim range as object
End Type


Sub Main

End Sub

Version: 6.0.2.1 (x64) Build ID: f7f06a8f319e4b62f9bc5095aa112a65d2f3ac89

tools->macros->edit macros>

compile

标签: compiler-errorsbasiclibreoffice-calc

解决方案


Dim declares local variables within subroutines. Type statements do not use it.

The reason this error was tricky to diagnose is that it looks like the problem is in Type xyz, but that part is fine. The IDE highlights whatever is before the first Dim statement, which may be a minor problem of the parser. The following code shows that even a comment can get highlighted!

Type xyz
    'This comment will be highlighted because of the Dim error.
    Dim sheet as object
End Type

This inaccuracy is not unusual for any compiler. Error messages often give clues to problems rather than telling exactly what and where the problem is.


推荐阅读