Archive for August, 2009

h1

VB.Net – Hide Form at Startup

28/08/2009

I’ve been using Microsoft Visual Basic 2008 (Express Edition) recently to create some utilities.  As part of this I needed to have an application start-up but only display as an icon in the system tray.  After attaching a notify icon control to my main form I set the form’s load method to set the display in task bar and visible properties of the form to be false.

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
notifyiconMain.Visible = True
Me.WindowState = FormWindowState.Minimized
Me.Visible = False
End Sub

However this code doesn’t have quite the effect you think it should – i.e. hiding the form and displaying the icon in the system tray.  What in fact happens (at least on Windows XP) is the window is squished up next to the start menu (the icon in the system tray is also there – as we would want).

That window shouldn't be visible

That window shouldn't be visible

These few lines of code work fine once the form is created and displayed, so the issue is definitely linked to the initial creation of the form.

After trying several options (such as minimise, restore, minimise) I succumbed to Googling for an answer and whilst I found lots of answers they were all complicated, a little laborious or just bad coding practice.  However I did find a different and surprisingly simple solution.

Rather than setting the window as minimised in the load method just set the WindowState property of the form to “Minimized“.  The load method then simply becomes…

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
notifyiconMain.Visible = True
Me.Visible = False
End Sub
h1

Excel: Last Entry

28/08/2009

I was challenged to work out a little problem someone was having with Excel today.  The expectation was that I could write some VBA to resolve it, but once I found out what the task was I quickly managed to put together a purely Excel function based solution.

The task was to pick the last entry from a vertical list of cells.  The list is sequential so there are no blank lines which makes the choice of algorithm to find the last entry quite open.   The algorithm I chose was based on a list length and vector approach.

Example

Example

So to start with I needed to know how many entries were in the list.  The COUNTA function will provide this.  This in effect tells us how many rows we have to step down to get to the last entry.  The OFFSET function allows us to carry out these steps based on the first entry in the list.  Because we’re starting at the first entry then we don’t need to move if there is only one entry, so we need to subtract one from the count to give us the number of “steps” to take from the first cell.

The screen shot illustrates how this is built up for a list in column A starting at cell A1.  The function we would use is simply =OFFSET(A1,COUNTA(A:A)-1,0,1,1)

However this does give us a #REF! if the list has no entries – which looks like an error if you give someone a blank list (essentially because it is).  So if you need to account for this, just include an IF.

=IF(COUNT(A:A)=0,””,OFFSET(A1,COUNTA(A:A)-1,0,1,1))

h1

Quit XBMC when it freezes (MAC)

24/08/2009

I run XBMC on a Mac Mini plugged into my TV.  Sometimes XBMC gets a bit caught up and freezes or gets locked into some sort of loop.  I have it running in full screen which makes it rather hard to quite when the application with focus is non-responsive.  So to get past this, press F8 to bring up Spaces and navigate to another space.  From here right click on XBMC in the dock to reveal and select Force Quit.

h1

Send Web Cam Pictures to EverNote with SnapIT

23/08/2009

Since Google Notebook went out of development earlier this year I’ve made the migration over to EverNote. It has many cool features one of the coolest being the ability to upload images and have EverNote run OCR to index the content of the image.  The mobile phone EverNote applications allow a phone’s camera to be used to take a snapshot image and to upload it to EverNote over a 3G connection.  Unfortunately the Windows desktop application has no functionality for capturing images in the same way through a web camera and with the proliferation of netbooks I feel that this is a feature that is sadly missing – well for me anyway.   So after a bit of research I embarked on a quick weekend VB.Net project to put together a little application that could do this – and so I created SnapIT.

SnapIT Main Screen

SnapIT Main Screen

SnapIT allows you to take a photo with an attached or built in camera (by pressing the “Capture Image” button) and save it (by pressing the “Store Image” button) to a specified folder as a JPEG with a file name based on the time at which it was taken.  It also allows you to send the image off to an EverNote database with options to specify which notebook it gets sent to (it will of course default to the default notebook), a title and tags (separated by commas).  Where the image ends up is determined by the checkbox options that have been selected (next to the “Store Image” button).

Settings window

Settings window

It’s a standalone executable and stores a few settings in an INI file it creates in the same folder.  When you first use it (assuming you want to save images or send them to EverNote) you will need to set a few file/folder paths.  This can be done from File > Settings.  You need to set a folder to store images in, the location of ENScript.exe (used to send the image to the database) and the location of the EverNote database file to which images should be sent.

This is just something I threw together for my own use and given that I wrote it in just a day or so it really hasn’t gone through much testing, so please keep that in mind when using it.  That being said if you find a bug then add a comment to this blog post and if I can reproduce it I may just find the time to fix it and post a new version.

h1

ENScript – Scripting Evernote in Windows

21/08/2009

This post has now been migrated to ThoughtAsylum.com.

Follow this link to go directly to the article.

h1

How to Feed Twitter to FeedBurner

20/08/2009

I tried adding my Twitter RSS feed to FeedBurner a little earlier.  Even though FeedValidator identified the feed as valid FeedBurner wouldn’t.  Googling this suggested that either Twitter isn’t producing nice RSS feeds (which FeedValidator’s validation seems to contradict) or FeedBurner has blocked it.

I decided to try passing the RSS feed through another tool.  I considered using Yahoo Pipes, but then decided that the feed aggregator from XFruits would be the quickest way.  I set-up a feed as an aggregation of just a single feed, passed that to FeedBurner and everything now seems to work.

h1

The Little Things

20/08/2009

I’ve just completed a few updates to the RebootIT and FlagIT blogs.  The main thing is I’ve changed the RSS feeds published on the site to got to Feed Burner and I’ve set them up there  to make use of the Pub Sub Hubbub so please consider updating any RSS subscriptions you might have.