VB 判断数据类型的函数 | 雨律在线

VarType() 函数返回的是 integer 型值,这个函数返回的是字符串。


Public Function getDataType(v As Variant) As String
Select Case
VarType(v)
Case vbArray
getDataType =
"vbArray"
Case vbBoolean
getDataType =
"vbBoolean"
Case vbByte
getDataType =
"vbByte"
Case vbCurrency
getDataType =
"vbCurrency"
Case vbDataObject
getDataType =
"vbDataObject"
Case vbDate
getDataType =
"vbDate"
Case vbDecimal
getDataType =
"vbDecimal"
Case vbDouble
getDataType =
"vbDouble"
Case vbEmpty
getDataType =
"vbEmpty"
Case vbError
getDataType =
"vbError"
Case vbInteger
getDataType =
"vbInteger"
Case vbLong
getDataType =
"vbLong"
Case vbNull
getDataType =
"vbNull"
Case vbObject
getDataType =
"vbObject"
Case vbSingle
getDataType =
"vbSingle"
Case vbString
getDataType =
"vbString"
Case vbUserDefinedType
getDataType =
"vbUserDefinedType"
Case vbVariant
getDataType =
"vbVariant"
Case Else
getDataType = "Unknown Data Type"
End Select
End Function


 
目前有0条回应
Comment
Trackback
你目前的身份是游客,请输入昵称和电邮!