Saturday, September 29, 2007

Pocket Outlook on Windows Mobile

The best reference (that I have found) for developing with Pocket Outlook on Windows Mobile can be found here:

These examples are in C#, but the conversion to VB.NET is pretty easy. Here is an example of some of the code in VB.NET:

Dim contactPicker As New ChooseContactDialog
Dim result As DialogResult = contactPicker.ShowDialog

If result = Windows.Forms.DialogResult.OK Then

Dim message As EmailMessage = New EmailMessage()
message.Subject = "GTViewer Photo"
message.BodyText = "........"

Dim addressee As Recipient = New Recipient(contactPicker.SelectedContact.Email1Address)

Dim picture As Attachment = New Attachment(filename)

Dim _outlook As OutlookSession = New OutlookSession()


End If

Sleep in VB.NET and C#

The sleep is sometimes hard to find in .NET. Here is an example for VB.NET and C#:


Imports System.Threading

Dim waitTime as Integer = 300



using System.Threading;
int waitTime = 300;


The Sleep method can be used with both an integer and a TimeSpan parameter. An integer value can be used to specify the wait time in milliseconds, or the wait time can be specified as a TimeSpan like this:


Dim waitTime As New TimeSpan(0, 0, 0, 0, 300)

or in C#:

TimeSpan waitTime = new TimeSpan(0, 0, 0, 0, 300);

There is also a pretty good example at the following web site:

Tuesday, September 4, 2007

Conditional Compilation in VB.NET

Like C and C++, you can perform Conditional Compilation in VB.NET:

#If COMMAND_LINE = True Then
Dim AxGTCreate1 As GTCREATELib.GTCreate = Nothing
Dim AxGTCreate1 As AxGTCREATELib.AxGTCreate = Nothing
#End If

The #if, #else, and #end if can be used.

In the example above, the variable COMMAND_LINE is used to determine which type to use. The COMMAND_LINE value is set either by using:

#Const COMMAND_LINE = True

in the code, or by setting it as a Custom Constant on the Compile table of the Project's property page. Press the Advanced Compile Options button to get to the form to set the Custom Constants.

Getting Command-Line arguments in a VB.NET Console Application

It is pretty simple to get a string of the command-line arguments in VB.NET:

Dim cl As String = Command()

It is still up to you to parse the string into something usable. Here is a link that show one approach: