PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Converting C# to VB .NET

Reply

Converting C# to VB .NET

 
Thread Tools Rate Thread
Old 03-03-2005, 12:14 AM   #1
Howard Kaikow
Guest
 
Posts: n/a
Default Converting C# to VB .NET


I'm converting some C# to VB .NET.

In an example that uses Outlook, I find the following C# statement:

Outlook.AppointmentItem appointment =
(Outlook.AppointmentItem)outlook.CreateItem(
Outlook.OlItemType.olAppointmentItem);

I do not understand how to convert the (Outlook.AppointmentIem) portion of
the statement.

--
http://www.standards.com/; See Howard Kaikow's web site.


  Reply With Quote
Old 03-03-2005, 12:28 AM   #2
Manohar Kamath
Guest
 
Posts: n/a
Default Re: Converting C# to VB .NET

Use CType

appointment =
CType(outlook.CreateItem(Outlook.OlItemType.olAppointmentItem),
Outlook.AppointmentItem)

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com


"Howard Kaikow" <kaikow@standards.com> wrote in message
news:%23Pr%23qX4HFHA.3608@TK2MSFTNGP14.phx.gbl...
> I'm converting some C# to VB .NET.
>
> In an example that uses Outlook, I find the following C# statement:
>
> Outlook.AppointmentItem appointment =
> (Outlook.AppointmentItem)outlook.CreateItem(
> Outlook.OlItemType.olAppointmentItem);
>
> I do not understand how to convert the (Outlook.AppointmentIem) portion of
> the statement.
>
> --
> http://www.standards.com/; See Howard Kaikow's web site.
>
>



  Reply With Quote
Old 03-03-2005, 03:10 AM   #3
Howard Kaikow
Guest
 
Posts: n/a
Default Re: Converting C# to VB .NET

Thanx.

I thought that it had to be something like that.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Manohar Kamath" <mkamath@TAKETHISOUTkamath.com> wrote in message
news:%23dF72f4HFHA.2740@TK2MSFTNGP12.phx.gbl...
> Use CType
>
> appointment =
> CType(outlook.CreateItem(Outlook.OlItemType.olAppointmentItem),
> Outlook.AppointmentItem)
>
> --
> Manohar Kamath
> Editor, .netWire
> www.dotnetwire.com
>
>
> "Howard Kaikow" <kaikow@standards.com> wrote in message
> news:%23Pr%23qX4HFHA.3608@TK2MSFTNGP14.phx.gbl...
> > I'm converting some C# to VB .NET.
> >
> > In an example that uses Outlook, I find the following C# statement:
> >
> > Outlook.AppointmentItem appointment =
> > (Outlook.AppointmentItem)outlook.CreateItem(
> > Outlook.OlItemType.olAppointmentItem);
> >
> > I do not understand how to convert the (Outlook.AppointmentIem) portion

of
> > the statement.
> >
> > --
> > http://www.standards.com/; See Howard Kaikow's web site.
> >
> >

>
>



  Reply With Quote
Old 03-03-2005, 03:21 AM   #4
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
 
Posts: n/a
Default RE: Converting C# to VB .NET

Howard:
Please feel free to download the Demo Edition of our Instant VB C# to VB.NET
converter at http://www.instantvb.com. The Demo Edition is very useful for
quickly converting small C# code snippets and it's fully supported.

Regards,
David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com
Home of the Instant VB C# to VB.NET converter and the Instant C# VB.NET to
C# converter

"Howard Kaikow" wrote:

> I'm converting some C# to VB .NET.
>
> In an example that uses Outlook, I find the following C# statement:
>
> Outlook.AppointmentItem appointment =
> (Outlook.AppointmentItem)outlook.CreateItem(
> Outlook.OlItemType.olAppointmentItem);
>
> I do not understand how to convert the (Outlook.AppointmentIem) portion of
> the statement.
>
> --
> http://www.standards.com/; See Howard Kaikow's web site.
>
>
>

  Reply With Quote
Old 03-03-2005, 11:07 AM   #5
Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
Default Re: Converting C# to VB .NET

Howard,

"Howard Kaikow" <kaikow@standards.com> schrieb:
> I'm converting some C# to VB .NET.
>
> In an example that uses Outlook, I find the following C# statement:
>
> Outlook.AppointmentItem appointment =
> (Outlook.AppointmentItem)outlook.CreateItem(
> Outlook.OlItemType.olAppointmentItem);
>
> I do not understand how to convert the (Outlook.AppointmentIem) portion of
> the statement.


'(Outlook.AppointmentItem)' is a type cast.

\\\
Dim Appointment As Outlook.AppointmentItem = _
DirectCast( _
outlook.CreateItem(Outlook.OlItemType.olAppointmentItem), _
Outlook.AppointmentItem _
)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

  Reply With Quote
Old 03-03-2005, 03:03 PM   #6
Howard Kaikow
Guest
 
Posts: n/a
Default Re: Converting C# to VB .NET

Thanks to those who responded.

I have two books that compare VB .NET and C#.

The one from O'Reilly loses much of its value as there is no index!

The one from APress has an inadequate index. For example, neither Ctype nor
DirectCast is listed in the index, however, if one knows that a conversion
function is required, there is an index item for conversion functions. So if
one already knows the language from which one is translating, the book could
be useful.

I guess one has to fully read such books, but as a reference, they are
inadequate.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Howard Kaikow" <kaikow@standards.com> wrote in message
news:%23Pr%23qX4HFHA.3608@TK2MSFTNGP14.phx.gbl...
> I'm converting some C# to VB .NET.
>
> In an example that uses Outlook, I find the following C# statement:
>
> Outlook.AppointmentItem appointment =
> (Outlook.AppointmentItem)outlook.CreateItem(
> Outlook.OlItemType.olAppointmentItem);
>
> I do not understand how to convert the (Outlook.AppointmentIem) portion of
> the statement.
>
> --
> http://www.standards.com/; See Howard Kaikow's web site.
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off