Excel VBA 中的 TypeName 返回什么? [英] TypeName in Excel VBA returns what?

查看:61
本文介绍了Excel VBA 中的 TypeName 返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

If TypeName(Cells(r, 1).Value) = "这里有什么?"然后MsgBox "是"别的MsgBox "不"万一

解决方案

深入了解

I want to check what data type is in: Cells(2, 1).Value i.e. "WHAT GOES HERE?" below.

I tried the names (Integer / Long etc.) but doesn't seem to accept.

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

Else
    MsgBox "No"

End If

解决方案

Well a look into MSDN reveals a table of possible return values

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

In addition you can also see the above table by using the built-in help (credit goes to Axel Richter). To quickly jump to the according page, select the function and press F1 or navigate to the help page via the object browser like so:

这篇关于Excel VBA 中的 TypeName 返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆