/Home /Archive /Syndicate /Blog /Support /About /Contact  
All Visual Basic Feeds in one place!





The Diary of a Long Voyage - learning VS 2005 and SQL Server 2005 from scratch

By Phoenix www.phoenix-vb.net

11th April - 17th April

Now that I am ready to start programming I need an application to write. My initial thoughts were that it has to be a simple one otherwise I would get bogged down with code writing and learning little new. Fortunately in VS2005 there is a lot of pre-written code which is available through the Snippet  tool. I had a look through this - all the standard code is in there - a great productivity aid. Not only that but there is a great little Snippet Editor/manager to allow you to put your own code into. This beats the VS2003 approach of writing functional libraries and including them into every project.

Now I have three different subject matter websites to maintain, all with completely separate links. Now to maintain these separate favourites/bookmarks has become tedious as I also use 3 separate browsers - IE, Firefox and Netscape. So what I have decided to write is a simple Windows application that maintains a library of favourites/bookmarks. This application will have a very simple interface which will remain on the desktop so as I find useful sites I can just drop them onto the window. Other design features:

- I will have multiple libraries so a function is to choose the library

- I want to start the application at logon time - so the exe will go in the startup group

- The exe will take the full name of the library - this means I will have to start with a function main and start the window from there

- The app will have to remember the desktop position where it was on previous invocation

- As the app may use multiple libraries then the desktop position will be dependent of the library

- Only one invocation of the app per library to avoid corruption of the library and confusion on the desktop

I plan to write the library using three storage types - flat file, MS SQL2005 and XML. By adopting a structured OO approach then moving from one to the other should mean only changes to the Data Access Object.

 

It is good practice to return an error code from command line applications so the basic code will be structured like this:

Function main (ByVal args() as string) as Integer

Try

    GetStartupParameters()

    Application.Run(New Mainform)

    Return 0

Catch ex as Exception

    Return 1

End Try

End Function

 

The 'My' namespace is new to VB 2005 and contains a huge amount of useful information that previously could only be obtained through API calls. In the bookmarks example I have used one function to get the command line arguments:

Function getArguments() As Integer

Try>

>

    Dim i As Integer = 0>>>

    Dim returnCode As Integer = 0>>>>

For Each argument As String In My.Application.CommandLineArgs

    ' this is the new feature in VB.NET 2005 to handle command line arguments>

    Select Case i>>

>        Case 0

            library = argument    ' this is the library file

>        Case 1

            positionFile = argument ' this is where the position is stored

>

        Case >>Else

>

>        ' ignore more than 2 parameters

>

    End >>Select

>

    i += 1 >' count number of arguments

>

>    Next

>

>    ' there must be 2 parameters for this to run correctly

>

    If i = 2 >>Then

>

        returnCode = 0

>    Else

>

        returnCode = 1

    End >>If

>

>Catch

>

End >>Try

>

End >>Function

>
© 2005 Serge Baranovsky. All rights reserved.
All feed content is property of original publisher. Designated trademarks and brands are the property of their respective owners.

This site is maintained by SubMain(), a division of vbCity.com, LLC