Thursday, February 25, 2010

dotNet Dictionary - ContainsKey

I think Dictionary objects are brilliant data structures. The way they can contain objects and nested dictionaries within them seleves makes them a fantasic store,

However I was using a Dictionary obect to store Key Value Pairs and I couldnt be sure that I knew if all the key's were present. The first way I found to check was to try to get the key within a Try Catch block and if they key wasnt found the Catch block would return a default value.

This was both stressfull to me and the performance of the app, so I was very pleased when I found a method to test if a key existed: Dictionary<(Of <(TKey, TValue>)>)..::.ContainsKey Method

BUT I was even happier when I found the Dictionary<(Of <(TKey, TValue>)>)..::.TryGetValue Method

TryGetValue means you dont need to wrap your code in Try Catch blocks to handle exceptions and you can pass back a default value if the key is not found. Brilliant !

A couple of Excel VBA usefull notes

UserName = Environ("Username")
Domain = Environ("UserDomain")
Combined= Environ("UserDomain") & "\" & Environ("Username")

CurrentDate = Date
CurrentTime = Time

Some file and folder VBA commands

Current folder name: CurDir
Change the active folder: ChDir "C:\My Documents"

File exists test: If Dir("F:\My Documents\My Workbook.xls") <> "" Then ....

Delete a file : Kill "F:\My Documents\My Workbook.xls"

Creates a new folder: MkDir "F:\My Documents\NewPrivateFolder"
Delete a folder: RmDir


Copy a file (the file must be closed): FileCopy "OrgWorkBook.xls", "CopyWorkBook.xls"

How to move a file (the file must be closed):

OldFilePath = "C:\OldFolder\Filename.xls" ' original file location
NewFilePath = "C:\NewFolder\Filename.xls" ' new file location
Name OldFilePath As NewFilePath ' move the file


My thanks to this reference - allbeit a little hard to read beacause of the ad's

February 2010 Windows Media Center Cumulative Update for Windows 7

Although Windows 7 Media Centre is much better than previous releases - its support of media extenders such as Xbox 360 and Linksys are woefully behind. Here is the latest patch for Windows 7 and I do hope that this is supported by the extenders being updated as well.

Sharepoint list item - custom drop down menu

To be able to customise Sharepoint Context menus easily using Javascript in a a Content Editor Web Part is extreemly powerfull and remarkably simple to get working. - see this article for guidance Customizing SharePoint Context Menus.

(Suplimental: The obove article is ok as far as it goes however to try to get the client side menu to carry out actions is not simple. You need to be skilled in Javascript and have a knowledge of the internal variable names Sharepoint 2007 users. [at least Sharepoint 2010 will have a client side dll!).

Other references I found usefull were :