Small b Systems blog

Information for small businesses

Some Visual Basic 2008 Hard Learned Lessons

clock August 30, 2009 11:45 by author Administrator

I just finished writing an application to automate the import of Outlook contacts into a Microsoft Jet Engine 4.0 database, which can be used by Access as well as the .Net languages.

The first, and hardest, problem to solve was fields in Outlook which contain no value are given a value of Nothing. Nothing means that the parameter does not exist and  an error is generated. I finally decided to assign each Outlook field to a string array variable. When I tested the string variable for Nothing, I got variable not declared error. I have never had this problem before. I still don't know why I got it, but this was the solution I found: Dim z As Array = Array.CreateInstance(GetType(String), 61).

Not much code but it took weeks to figure out.

There is another way to do. Test Outlook field directly as follows:

If    objContact.FirstName isNothing Then

      command.Parameters.Add(New OleDbParameter("FirstName", objContact.FirstName)).Value=""
else
      command.Parameters.Add(New OleDbParameter("FirstName", objContact.FirstName))

End If

There is a lot less typing assigning each Outlook field to an array variable and testing as follows:

For i = 0 To 60
  If z(i) Is Nothing Then
    z(i) = ""
  End If
Next

My last tip is Clear the parameters collection before starting a new loop. If you don't the first set of values will be inserted for each loop.

command.Parameters.Clear()
   'If you don't clear parameters, it will repeat first value.
command.Parameters.Add(New OleDbParameter("Assistant", z(0)))

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


FREE PROGRAM - Message Board for your desktop

clock August 8, 2009 07:29 by author Administrator

Free Message Board Program

This program has 8 boxes in which you can enter, or paste, large amounts of text and images. You can use the tab to align your text and the enter key for newline. Each box can be moved to any position with the mouse. Right clicking the mouse brings up a menu to change the font, font color,background color, right, left, center align selected text, bullet text, insert current date and/or time and save the contents of the active box.

The individual text boxes are saved in their own Rich Text files which can be read by any word processor and will retain all formatting.

Below is a screen capture.

Screen capture of Message Board windows
Click here to download Message Board

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


About the author

My name is Paul Steinberg and I am the owner of Small b Systems. I am 71 years old and have been working with computers for 32 years. I have been designing business and manufacturing systems for 49 years.

A system is a collection of orgainized tasks which guide an operation to a predictable conclusion. Unlike an individuals's routine, a system can be used by anyone.

I have worked on Wall Street, in military electronics, retailing, professional photography, manufacturing, barter and woodworking. I have designed systems in all of these industries.

Sign in