gpt4 book ai didi

vba - "User-defined type not defined"用于简单自定义类型

转载 作者:行者123 更新时间:2023-12-02 00:54:22 46 4
gpt4 key购买 nike

在 Excel 2007 中,我有以下非常简单的 VBA 代码:

Public Type specType
sb As Long
End Type


Private Sub MyButton_Click()
Dim spec As specType

'...
End Sub

单击按钮时,我在“Dim spec As specType”行上收到“用户定义的类型未定义”错误...为什么?我是否必须将用户定义的类型移至特殊位置?

最佳答案

事实证明,类型必须在模块中的任何函数之前定义,否则它们根本不会被识别(不会给出错误)。

关于vba - "User-defined type not defined"用于简单自定义类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4679822/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com