473,480 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Strict On

Hi, I'm trying to retreive outlook contact info with the phone number...

I code this with Option Strict On:

Dim myApp As New Outlook.Application
Dim contact As Outlook.ContactItem
Dim espace As Outlook.NameSpace
Dim contacts As Outlook.MAPIFolder

myApp = New Outlook.Application
espace = myApp.GetNamespace("MAPI")
contacts = espace.GetDefaultFolder(OlDefaultFolders.olFolderC ontacts)

contact = contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX") <<<---
Error

Me.Text = contact.FullName

And I have this error:

Option Strict On disallows implicit conversions from 'System.Object' to
'Outlook.ContactItem'.

I know Strict option is used for not melting types, but I don't know how
declare contact...

Any help ?

TIA
Nov 20 '05 #1
4 1784
"Peter Osawa" <po****@sun.es> schrieb
I code this with Option Strict On:

Dim myApp As New Outlook.Application
Dim contact As Outlook.ContactItem
Dim espace As Outlook.NameSpace
Dim contacts As Outlook.MAPIFolder

myApp = New Outlook.Application
espace = myApp.GetNamespace("MAPI")
contacts =
espace.GetDefaultFolder(OlDefaultFolders.olFolderC ontacts)

contact = contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX")
<<<--- Error

Me.Text = contact.FullName

And I have this error:

Option Strict On disallows implicit conversions from 'System.Object'
to 'Outlook.ContactItem'.


I don't know the object model, but I guess the return type of the Find
function is Object. This means the function could return any type of object,
so you'd get a runtime error if the object's type is not
Outlook.ContactItem. So, if you are sure that the function will always
return a Outlook.ContactItem object, you can write:

contact = directcast( _
contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX"),
Outlook.ContactItem _
)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
use CType for type casting. also, look up DirectCast and the difference between these two

tr
contact=CType(contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX"), outlook.contactitem
catc
'handle erro
finall
end tr

----- Peter Osawa wrote: ----

Hi, I'm trying to retreive outlook contact info with the phone number..

I code this with Option Strict On

Dim myApp As New Outlook.Applicatio
Dim contact As Outlook.ContactIte
Dim espace As Outlook.NameSpac
Dim contacts As Outlook.MAPIFolde

myApp = New Outlook.Applicatio
espace = myApp.GetNamespace("MAPI"
contacts = espace.GetDefaultFolder(OlDefaultFolders.olFolderC ontacts

contact = contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX") <<<--
Erro

Me.Text = contact.FullNam

And I have this error

Option Strict On disallows implicit conversions from 'System.Object' t
'Outlook.ContactItem'

I know Strict option is used for not melting types, but I don't know ho
declare contact..

Any help

TI

Nov 20 '05 #3
Thank you very much !!!

"tMan" <an*******@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
use CType for type casting. also, look up DirectCast and the difference between these two.
try
contact=CType(contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX"), outlook.contactitem) catch
'handle error
finally
end try

----- Peter Osawa wrote: -----

Hi, I'm trying to retreive outlook contact info with the phone number...
I code this with Option Strict On:

Dim myApp As New Outlook.Application
Dim contact As Outlook.ContactItem
Dim espace As Outlook.NameSpace
Dim contacts As Outlook.MAPIFolder

myApp = New Outlook.Application
espace = myApp.GetNamespace("MAPI")
contacts = espace.GetDefaultFolder(OlDefaultFolders.olFolderC ontacts)

contact = contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX") <<<--- Error

Me.Text = contact.FullName

And I have this error:

Option Strict On disallows implicit conversions from 'System.Object' to 'Outlook.ContactItem'.

I know Strict option is used for not melting types, but I don't know how declare contact...

Any help ?

TIA

Nov 20 '05 #4
"Peter Osawa" <po****@sun.es> schrieb
I code this with Option Strict On:

Dim myApp As New Outlook.Application
Dim contact As Outlook.ContactItem
Dim espace As Outlook.NameSpace
Dim contacts As Outlook.MAPIFolder

myApp = New Outlook.Application
espace = myApp.GetNamespace("MAPI")
contacts =
espace.GetDefaultFolder(OlDefaultFolders.olFolderC ontacts)

contact = contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX")
<<<--- Error

Me.Text = contact.FullName

And I have this error:

Option Strict On disallows implicit conversions from 'System.Object'
to 'Outlook.ContactItem'.


I don't know the object model, but I guess the return type of the Find
function is Object. This means the function could return any type of object,
so you'd get a runtime error if the object's type is not
Outlook.ContactItem. So, if you are sure that the function will always
return a Outlook.ContactItem object, you can write:

contact = directcast( _
contacts.Items.Find("[BusinessTelephoneNumber]=0558XXXX"),
Outlook.ContactItem _
)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2118
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
10
3087
by: Mark McLellan | last post by:
Dear all Following the oft-repeated advice here and ciwas I have made my site nearly 4.01 strict (working on it). There are some items on which I would appreciate your advice: 1. Hidden...
13
9603
by: Kieran | last post by:
I am designing a content management system and I want to make sure all pages entered into it's database by users are using valid HTML. I have designed the system to use HTML 4.01 Transitional...
1
6796
by: Andy Crawford | last post by:
Even though I have set Strict Off, it is still on, thus causing this error. Here is the code in a templated Column of a DataGrid: (XPpro, Framework 1.1) <ItemTemplate> <TABLE width="100%">...
11
2096
by: Daylor | last post by:
hi. im using option strict on. im doing in ,from the simple reason ,to be warn when there are implict conversion like string to int ,int to string. BUT. the price ,(now i see ), is very bad....
8
1807
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
17
4458
by: David | last post by:
Hi all, I have the following problem: my program works fine, but when I add option strict at the top of the form, the following sub fails with an error that option strict does not allow late...
8
2408
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the...
8
3874
by: =?Utf-8?B?R3JlZw==?= | last post by:
We have an application in our office that has the Option Strict option set to off right now. I do understand it should be set to ON, but right now, I'm just going to continue with it this way since...
92
5056
by: Erwin Moller | last post by:
Hi group, I encoutered page validation error, but I don't know a way around. The page has the following doctype: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"...
0
7044
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7045
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6741
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4483
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2985
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.