gpt4 book ai didi

vba - Excel VBA 中的 TypeName 返回什么?

转载 作者:行者123 更新时间:2023-12-02 23:22:51 25 4
gpt4 key购买 nike

我想检查以下数据类型:Cells(2, 1).Value 即“这里有什么?”以下。

我尝试了名称(整数/长整型等),但似乎不接受。

If TypeName(Cells(r, 1).Value) = "WHAT GOES HERE?"  Then
MsgBox "Yes"

Else
MsgBox "No"

End If

最佳答案

看看MSDN显示可能的返回值表

String Returned     Variable
-------------------------------------------------------------------
Object type An object whose type is objecttype
Byte Byte value
Integer Integer
Long Long integer
Single Single-precision floating-point number
Double Double-precision floating-point number
Currency Currency value
Decimal Decimal value
Date Date value
String String
Boolean Boolean value
Error An error value
Empty Uninitialized
Null No valid data
Object An object
Unknown An object whose type is unknown
Nothing Object variable that doesn't refer to an object

此外,您还可以使用内置帮助查看上表(感谢 Axel Richter)。要快速跳转到相应页面,请选择该功能并按 F1 或通过对象浏览器导航到帮助页面,如下所示:

enter image description here

关于vba - Excel VBA 中的 TypeName 返回什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38365630/

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