|
-
Sep 5th, 2001, 06:02 AM
#1
Thread Starter
Fanatic Member
Testing DataTypes
Is there a function for testing the actual datatype of an object? I have an application that should run a certain procedure whenever an Outlook.MailItem is opened, by passing the Inspector.CurrentItem into the procedure as a parameter. However, if the user actually opened a read-receipt, this causes an error because the Inspector.CurrentItem is now an Outlook.ReportItem instead.
Is there a way of saying something like:
VB Code:
If DataType(Inspector.CurrentItem) = Outlook.MailItem Then
TIA...
-
Sep 5th, 2001, 06:06 AM
#2
Retired VBF Adm1nistrator
Well there's the TypeName() function.
But I dont know if it'll work with these sorts of types.
If it doesnt, then you could infer what sort of data type it is.
Something like :
VB Code:
Private Function GetDataType(myObj As Variant) As String
'check the different properties of the control and infer what it is
End Function
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 5th, 2001, 06:16 AM
#3
Thread Starter
Fanatic Member
Jamie,
Didn't know about the TypeName function, but it works a treat. Thanks.
-
Sep 5th, 2001, 06:17 AM
#4
Retired VBF Adm1nistrator
Or you could try passing the variable to a set of functions, each one of which is expecting a specific data type.
You catch the errors, and check which one didnt throw an error.
Then you know what type it is.
I think this is how I would do it.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|