Archive for the ‘General’ Category


September 22, 2011 1 comment

So I have had the chance to play with Google+ for a day now. So far I am liking what I see. Especially the G+ app on the DROID. That’s where it really seems to come together. I think I just might become more active on G+ than I am on FB.

Categories: General, Technology

How to NOT Run a Contest

April 18, 2011 2 comments

Microsoft has announced anew contest called “Ready for Work”. I happened to come across this while reading a recent article on ComputerWorld about Microsoft broadening Office 365 Beta. The article stated that: “Five winners will receive a $50,000 marketing package, Office 365 and a day’s work from a Microsoft executive.” Intrigued, I decided to click the link provided. And that’s where things go wrong.

Let me just say I don’t blame ComputerWorld for the subterfuge, I think in this case, they were simply passing along the PR feed that came from Microsoft. Not a biggie. But with what Microsoft did is what I’d consider inexcusable and a horrible way to attract attention to the contest. Firstly, the url that was given is a seemingly innocuous one: Seems reasonable. Only it is a redirect to a FaceBook page.

OK, so MS is attempting to use social media for the contest. But when you look at the page you can see… or rather not see… there’s no details about the contest. All you get is that there is a contest, and if you want to continue you have to click “Like.” What?

So, to find out more about this contest that I may or may not participate in, I have to first “like” it. I’m sorry, but that’s not the way to run a contest. I think it is a perfectly good and valid way to PROMOTE it, but leave the details public, let me see what the contest is all about. THEN if I decide I want to participate I will. If I then also want to share it with my other friends, most of whom are not in the IT business, then I will “like” the page and promote it. But liking a FaceBook page should not be a requisite to being able to read the details of a contest.

And then I clicked the “Back” button on my browser. Which went back to the redirect, sending me right back to FaceBook. Yet one more strike. Click, click, click. Nothing. To get out, I had to dropdown the history list, select the ComputerWorld item.

Microsoft, I am not sure whose idea this was but I think they need to be flogged. I shouldn’t be required to like a FaceBook page just to get details of a contest, and when I click that Back button, LET ME OUT! Don’t trap me. Clearly, the redirects and the FB pages did not go through RC or CTP or any kind of Beta review. Next time, consider at least SOME kind of focus group review. Either way, this is an example of how to not run a contest.

Categories: General, Technology

Google’s PeopleFinder service for earthquake

March 11, 2011 Leave a comment

In response to this morning’s earthquake in Japan, Google has launched a PeopleFinder service to help family and friends find each other.

Link to article:

Direct Link to service:

They are currently tracking roughly 7,200 people…

I know I gave up social media for Lent, but I think in this case, it’s important. I’m posting this through my blog which goes out automatically to FaceBook and Twitter…

Categories: General, Personal

Debugging 101

March 3, 2011 Leave a comment

As a frequent visitor and contributor to VBForums, I am constantly amazed at the number of times when some one suggests that the code needs to be debugged or stepped through, and the response is “How do I do that?” Granted, there is a great number out there that are learning programming on their own, and it may or may not be something that is obvious. In other cases, it’s apparent the debugging isn’t being taught in many classes. I find this a little sad if not maddening. Part of the interview process of my previous job was to go through some unfamiliar code (based on VB6) in an unfamiliar IDE (if it can be called an IDE, it was texted based, almost like I was back in DOS). I had been given some basics of what the app was supposed to do when it was done, and what errors it was generating. The accompanying information sheet then also gave a quick break down of the commands needed to use the IDE. For those really new, IDE stands for Integrated Development Environment. Visual Studio is an IDE. Mono, Eclipse are examples of two more. There are others, but you get the idea.

In my opinion, debugging is such a simple and basic technique that I’m surprised it isn’t taught in may curriculum. and yet, here we are with a great number of people that simply do not know how to debug properly. So I am going to run through some of the more typical ways one would debug an application. While the focus will be on tackling a VB.NET app, most will also be applicable to C#, and where I can, I’ll also share some VB6 equivalents.

Message Boxes

Generally debugging involves two kinds of thinking. The first is the logic flow, where is the path of execution going? The other is what is the value of something? The where and the what. the quickest and dirtiest method for this is to use Message Boxes. I’ve done this… in an attempt to find out where the heck my application is running off too, I’ve peppered my code with MessageBox.Show() (or MsgBox in VB6) with unique messages to let me know where the execution is going. The good aspect is that they are super easy to put in, copy and paste, paste, paste. The down side is if you use too many, you spend more time clicking  “OK” and may hit it with out paying attention to the messages, and so you then wonder where the heck you just were.  Another problem with using Message Boxes is their tendency to stop execution, as well as take focus away from the current form. I’ve run into problems with both of these before, needless to say I don’t use that method very much any more.Plus if you stick in in a loop, if it is sizable, you’re going to be clicking a lot of OK buttons.

Debug Print

The next typical debugging method is to use Debug.Print (for write, writeline, or even the Assert class). This dumps the output to the output window in the IDE. This handy for high-speed code or loops, where there’s a lot of messages. Saves the wear and tear on your mouse as you don’t need to click an OK button each time a message goes out. And since it goes into the Output Window in the IDE, even after you stop the app, you can view what what printed out. Most of it at any rate. The window does have a limit on the number of lines. You can also get a lot more complex on the output, adding some basic formatting. I do this when checking data in parent/child relations, or in a loop. the header will be fully left justified, and child data will be indented or offset in some manner.

That’s it for the really and truly basics of debugging. Using Message Boxes and debug print statements should be basic techniques that work in just about any language or IDE that supports them. A word of caution. Message Boxes WILL ship with the app if you forget to take them out, so be careful to remove every that you add. Debug.Print statements, while they will compile with the app, they only have meaning during a debug run of the app in the IDE.

Next up I’ll show how to use breakpoints, and how to determine variable state & values using intellisense, the watch window and the quick watch feature.

Read more…

Categories: General, Technology, Tutorials

Why Default Form Instances need to die

March 2, 2011 Leave a comment

And I’d like to see them die a quick and painless death too. Just rip it out, like a band-aid, the quicker the better.

I came across a thread today where the poster was wanting to know why code they had used worked on one form, while the seemingly same code was not working on another form. (I’ll spare the poster the embarrassment of linking to the post directly. At least it’s not their fault… but I’ll get to that eventually.)

Here’s the “working” code in question (from the load event of Form2):

Me.Text = form1.textbox1.text

The intent of the code is straight forward and simple: Make the title of the current form the value that is found in Textbox1 on Form1. This is actually quite a simple and common request. Something on the current form is dependent upon something in a different form.

Now here’s the code in question that doesn’t work (from the Load event of Form3):

me.text = Form2.textbox1.text

Look familiar? It should. It is “exactly” like the previous code snip, right? But according to the poster “it doesn’t work.” The poster then goes on to note that there are no error messages or anything else, it simply isn’t setting the caption of the form to the value “found” on form2. This is one of the pitfalls of default form instances and is what trips up most people.

At this point in the thread, what isn’t known is how form2 is being shown. What is suspected is that the poster has done something like this:

Dim someForm As New Form2
someForm.Show 'This causes the form to load and run the code in the Load event

What we end up with in this case is an instance of Form2 is being created and shown. And this is a good practice. But it is not the default instance. So if the same code is then used to show form3, when it loads, it attempts to get the data from instance Form2. But the instance that was created and is being displayed is someForm. So when Form3 (or any instance of it) loads, it tries to get its data from the defauit instance of Form2 which doesn’t have the data.

So, you maybe wondering how come it worked when Form2 was loaded? Shouldn’t have form2 come out blank since it was accessing Form1, which is also the Default Instance as well? Yes and no.

Yes, in theory it shouldn’t work either, but presuming that Form1 is the default start up form for the project/application, the default instance of the form is what is being used. This is why when the Load event for Form2 fires off, it was able to get the data from Form1, because in this case, Form1 really did exist.

Great, so what we do about it? Until Microsoft comes back to their senses, we are stuck with it and its repercussions. Default forms was originally removed from VB with the original Frameworks (1.0/1.1 – VB2002/VB2003) but was then added back in starting with Framework 2.0 (VB2005). I’ve been lamenting that move ever since. In my opinion it was a step backwards in the evolution of VB (one of several… topic for another time). In the meantime, be aware of default forms, avoid using them if you can. Now, I will admit, there MAY be some cases where using them makes sense, and should be used with extreme caution, both eyes open and full awareness of what the impact is going to be.

This does expose another issue, however. If you have a FormB that needs data from FormA, but you aren’t using default form instances, how does FormB know about the FormA instance to get the information? In short, it doesn’t. It never should. It should never care that it’s caption came from FormA, FormZ , Form007 or Form99. the best way to solve this kind of problem is through parametrized constructors.

Example of a parametrized constructor:

    Public Sub New(ByVal NewCaption As String)

        ' This call is required by the Windows Form Designer.

        ' Add any initialization after the InitializeComponent() call.
        Me.Text = NewCaption

    End Sub

This takes a single parameter and uses that value to set the caption of the form.

Dim newForm As Form1 = New Form1("A New Form Caption")

As you can see, now when we create the instance of the new form, we pass it the info it needs. It no longer is dependent upon any other form. And now we can re-arrange the forms. So instead of FormA calling FormB and formB calling FormC…. we cna have FormA call FormC and FormC cna call FormB. And the forms are none the wiser.

All too often I see people getting hung up because they’ve unknowingly mixed instanced forms with the default ones. I think this is a concept whose time has long since come and gone and it’s time to give up the crutch. Problem is that because this is something that is baked into the language itself (it’s not part of the Framework, but the VB language itself) it’s easier to get things in than it is to get things out. So we’re stuck with it for better or for worse.

Categories: General, Technology


February 8, 2011 1 comment

I’ve decided that it’s time to properly resurrect this blog. And I think I have finally found a voice for it. We’re going to be going back to the basics here. I’ve recently seen a number of postings on forums where a fundamental understanding was missed or misunderstood or abused. I plan to use this as a venue for either correcting it, pointing out my own opinions, or simply posting different tutorials on things.

This is going to happen in a number of steps. The first of which is going to be the cleaning out of all old posts. Zappo.

Second will be cleaning up the site, getting the title, tag line and the look to the way I want, befitting the direction things are going. Since it is a hosted site, I’ll need to see what kind of customizations I can do.

Thirdly, and lastly, start writing. At least once a week. If I can manage it, there will be a tutorial a week, with daily commentary, soap boxes, or discussions.


Categories: General