Archive

Archive for March, 2011

Firefox 4.0 – FAIL

March 24, 2011 Leave a comment

The new Firefox 4.0 rolled out recently. First impressions was that it looked eerily similar. In fact, out of the box, it looked just like my Opera installation. It has the application menu button in the top left, tabs go across from there, with the navigation buttons and address bar contained within the tab.

It was quick, loading most sites that I visit almost as quickly as my Kindle can turn pages. The use of graphics acceleration, even on XP (see Microsoft? It can be done if you really wanted to). I used FF4.0 for roughly 30 minutes.

And then I un-installed Firefox. Three words I thought I’d never utter: I un-installed Firefox.

So what happened? Put simply, Firefox was ignoring settings I had painstakingly  (not really, but I tinkered with the config to get the original effect) set. I use Firefox not only as a browsing tool, but a communication tool. That means not only do I have multiple tabs open, but I often have various windows open. And that’s where Firefox 4.0 failed me.

Often I open these other windows, then close the main one. Later I might come back and open a new window for something. When I open a new instance of Firefox, I expect to get a new window, with the homepage loaded up. That’s what the settings are set to, and I even had gone into the config area to make sure that when it recovers from a crash it doesn’t try to open the same sites I had open at the time of the crash (I had a site that caused a loop because it crashed the browser, and when it re-opened, it would open the faulty site, causing it to crash… well, you can figure out how that went).

To my dismay, I found out that as long as I had those other windows open, when I opened a new browser window, it would RELOAD EVERYTHING I HAD from the previous session. That means if I had 10 tabs open when I closed Firefox… it would re-open ALL 10 of those tabs/sites. Once I discovered this, and rechecking the settings and configuration, and unable to find a reason for this behavior, I decided that this was unacceptable to me and promptly gave Firefox 4.0 my stamp of “FAIL” and un-installed it.

Mind you, this is my experience with it.  It just so happens that it doesn’t fit my needs. Other than it trying to restore my pages when I re-open it, I thought it was quite good. The other down side is that, at least on the surface, it looks just like all the other browsers (except IE) out there. Most of the advances are under the hood with the graphics acceleration, and the support for HTML5 (what the heck is a Bieber?)

It’s good, it’s quick – even on the machine I was using it on, which isn’t exactly top of the line or known to be a speed demon. Again, it just no longer fit my needs. And so Firefox and I parted ways. Unfortunately, IE is now what I use. As unreliable as it can be, it’s predictably unreliable.

Categories: Technology

Apple’s iPhone Daylight Savings Time bug – redux

March 14, 2011 Leave a comment

This isn’t the first occurrence of the DST bug in the ever popular iPhone.

The same glitch in the iPhone’s clock that made loads of Europeans late to work last November has struck back with a vengeance. Instead of springing forward or standing still, many Verizon iPhone owners found that on Sunday their phones had fallen back, making them not only irritable and confused, but two hours off schedule.

(source: ComputerWorld)

A couple of things surprise me about this.

  1. This happened before.
  2. Where’s the outcry?

As noted in the CW article, this happened last year in Europe. And if I recall, it happened in the US once before as well, when the DST was expanded. Is determining if the phone should be on DST or not really that hard? I’ve done the calculations before, I don’t recall them being anything tricky, IF such and such date is the start of DST, and the hour is 2am, Then Add One Hour. OK, so not all states support DST. OK, Windows allows for this. It’s the “Adjust for DST” setting in the Date Time configuration. If you’re in Arizona, you know to turn that off. Apple? Are you listening? Want to make it even easier? If GPS is turned on, and I am in Arizona, leave my clock alone. Otherwise adjust it.

The first I heard about it, was on the local news this morning. And in passing. It wasn’t until about 20 minutes ago that I found the first article on it on CW. And again, it was a mention. Had it been a Win7 phone that had done this, Microsoft would have been crucified. I can just imagine Steve Job’s response “Just don’t calender it that way.” Or some other comment that seems out of touch.

Oh, and for the “solution”… turn the phone off then back on. Seems Apple DOES steal ideas from Microsoft after all.

I’s also like to note, my Droid had no problems what so ever. Neither did my win7 laptop.

Categories: 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: http://www.computerworld.com/s/article/9214204/Google_launches_Person_Finder_for_Japanese_quake_victims

Direct Link to service: http://japan.person-finder.appspot.com

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

VB6 Binary Compatibility

March 10, 2011 Leave a comment

This is another reprint of an article I originally wrote on VBForums. In it I show how to set Binary Compatibility on your VB6 component libraries (this works for OCXes as well as DLLs of the ActiveX variety).

Enjoy!

Read more…

Categories: Technology, VB6

Cloning VB6 Recordsets

March 4, 2011 Leave a comment

This is a re-printing of an article I originally posted on VBForums.com. In it I describe a problem I was having with the Clone method of the Recordset object in VB6, and then go on to explain a function I wrote to overcome the problems and limitations. the article is re-printed in its original text, unedited except for a few minor formatting issues. I never did get around to the refinements I wanted to make.


There have been a number of times when I found myself needing two independent copies of the same recordset.
ADO provides a .Clone function, but it doesn’t truly clone or copy the recordset. What it gives you is a second pointer to the same recordset.
They are still connected. I needed a way to not only scroll through the recordsets independent of each other, but I also needed a way to sort, filter, and update the information independent. Using .Clone wouldn’t allow me to do that.
So I built a better mousetrap.
Read more…

Categories: Technology, Tutorials, VB6

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.
        InitializeComponent()

        ' 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