دالة VarType في VBScript

التعريف والاستخدام

يمكن أن تعود دالة VarType قيمة تُشير إلى نوع الفرعية للمتغير المحدد.

القيم التي يمكن أن تعودها دالة VarType:

الرقم ثابت القيمة Description
vbEmpty 0 غير معيّن (الافتراضي)
vbNull 1 لا يحتوي على أي بيانات معتبرة
vbInteger 2 نوع فرعي لعدد كامل
vbLong 3 نوع فرعي لعدد طويل
vbSingle 4 نوع فرعي لعدد وحيد الدقة
vbDouble 5 نوع فرعي لعدد ثنائي الدقة
vbCurrency 6 نوع فرعي لعملة
vbDate 7 راجع أو وقت
vbString 8 String Value
vbObject 9 String Subtype
vbError 10 Error Subtype
vbBoolean 11 Boolean Subtype
vbVariant 12 Variant (only for variable arrays)
vbDataObject 13 Data Access Object
vbDecimal 14 Decimal Subtype
vbByte 17 Byte Subtype
vbArray 8192 Array

Note:These constants are specified by VBScript. Therefore, these names can be used anywhere in the code to replace actual values.

Note:If the variable is an array, VarType() will return 8192 + VarType(array element). For example, the VarType() of an integer array will return 8192 + 2 = 8194 .

Syntax

VarType(varname)
Parameter Description
varname Required. The name of the variable.

Example

dim x
x="Hello World!"
document.write(VarType(x))
x=4
document.write(VarType(x))
x=4.675
document.write(VarType(x))
x=Null
document.write(VarType(x))
x=Empty
document.write(VarType(x))
x=True
document.write(VarType(x))

Output separately:

String
Integer
Double
Null
Empty
Boolean