Option Compare Database
Option Explicit
Private Sub Form_Load()
Msg.Enabled = True
Msg.Locked = False
Msg.Value = ""
Dim i As Byte
For i = 0 To 13
Msg.Value = Msg.Value & "As " & GetType(Me("f" & i).Value) & vbCrLf
Next i
Msg.Locked = True
Msg.Enabled = False
End Sub
Public Function GetType(var As Variant) As String
Select Case VarType(var)
Case vbEmpty
GetType = "vbEmpty"
Case vbNull
GetType = "vbNull"
Case vbInteger
GetType = "vbInteger"
Case vbLong
GetType = "vbLong"
Case vbSingle
GetType = "vbSingle"
Case vbDouble
GetType = "vbDouble"
Case vbCurrency
GetType = "vbCurrency"
Case vbDate
GetType = "vbDate"
Case vbString
GetType = "vbString"
Case vbObject
GetType = "vbObject"
Case vbError
GetType = "vbError"
Case vbBoolean
GetType = "vbBoolean"
Case vbVariant
GetType = "vbVariant"
Case vbDataObject
GetType = "vbDataObject"
Case vbDecimal
GetType = "vbDecimal"
Case vbByte
GetType = "vbByte"
Case vbUserDefinedType
GetType = "vbUserDefinedType"
Case vbArray
GetType = "vbArray"
Case Else
GetType = "TypeCode: " & VarType(var)
End Select
End Function
以下是引用zhengjialon在2005-8-30 9:43:00的发言:
不错!
不过GetType函数改成:
Public Function GetType(var As Variant) As String
GetType = VarType(var)
End Function
是否可行?我没有试过是否有可能出现错误的地方.
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |