Converting C# to VB .NET

  • Thread starter Thread starter Howard Kaikow
  • Start date Start date
H

Howard Kaikow

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.
 
Use CType

appointment =
CType(outlook.CreateItem(Outlook.OlItemType.olAppointmentItem),
Outlook.AppointmentItem)
 
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,

Howard Kaikow said:
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 _
)
///
 
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.
 
Back
Top