在 VBScript 中获取变量的类型 [英] Get the type of a variable in VBScript

查看:20
本文介绍了在 VBScript 中获取变量的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 VBScript 获取变量的类型?

解决方案

Is VarType 你需要什么?

<块引用>

返回一个表示变量子类型的值.

+--------------+-------+--------------------------------+|常数 |价值 |说明 |+--------------+-------+-------------------------------------------+|vb空|0 |空(未初始化)||vbNull |1 |空(无有效数据)||vbInteger |2 |整数 ||vbLong |3 |长整数 ||vbSingle |4 |单精度浮点数 ||vbDouble |5 |双精度浮点数 ||vbCurrency |6 |货币 ||日期 |7 |日期 ||字符串 |8 |字符串 ||对象 |9 |自动化对象 ||错误 |10 |错误 ||vbBoolean |11 |布尔值 ||vbVariant |12 |变体(仅用于变体数组)||vbDataObject |13 |数据访问对象 ||vb十进制|14 |十进制值 ||字节 |17 |字节 ||vbLongLong |20 |LongLong 整数(64 位)||数组 |8192 |数组 |+--------------+-------+-------------------------------------------+

<块引用>

VarType 函数从不单独返回 Array 的值.它总是添加到某个其他值以指示一个数组特定类型.Variant 的值仅在具有已添加到 Array 的值以指示VarType 函数是一个数组.例如,返回的值整数数组计算为 2 + 8192 或 8194.如果一个对象有默认属性,VarType(对象)返回其默认类型财产.

How do I get the type of a variable using VBScript?

解决方案

Is VarType what you need?

Returns a value indicating the subtype of a variable.

+--------------+-------+---------------------------------------------+
|   Constant   | Value |                 Description                 |
+--------------+-------+---------------------------------------------+
| vbEmpty      |     0 | Empty (uninitialized)                       |
| vbNull       |     1 | Null (no valid data)                        |
| vbInteger    |     2 | Integer                                     |
| vbLong       |     3 | Long integer                                |
| vbSingle     |     4 | Single-precision floating-point number      |
| vbDouble     |     5 | Double-precision floating-point number      |
| vbCurrency   |     6 | Currency                                    |
| vbDate       |     7 | Date                                        |
| vbString     |     8 | String                                      |
| vbObject     |     9 | Automation object                           |
| vbError      |    10 | Error                                       |
| vbBoolean    |    11 | Boolean                                     |
| vbVariant    |    12 | Variant (used only with arrays of Variants) |
| vbDataObject |    13 | A data-access object                        |
| vbDecimal    |    14 | Decimal Value                               |
| vbByte       |    17 | Byte                                        |
| vbLongLong   |    20 | LongLong integer (64 bit)                   |
| vbArray      |  8192 | Array                                       |
+--------------+-------+---------------------------------------------+

The VarType function never returns the value for Array by itself. It is always added to some other value to indicate an array of a particular type. The value for Variant is only returned when it has been added to the value for Array to indicate that the argument to the VarType function is an array. For example, the value returned for an array of integers is calculated as 2 + 8192, or 8194. If an object has a default property, VarType (object) returns the type of its default property.

这篇关于在 VBScript 中获取变量的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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