Wednesday, September 25, 2013

"Which one do I want to save?"

I find it annoying to have to read this everywhere I go in Windows 7. "What should I do?" or similar options in many Windows 7 applications that basically convey, "I don't know what I want. Microsoft, tell me what to do." Now hold on, I do understand there may be people who are not used to computers or are older, and they are not used to it. But still - when you're offered two options that clearly differentiate themselves, you should be able to know what you want to do.

I.E. - In Burn a Disc. You have the option to write anytime, or only write once. Gee, that's a thinker. If I want to be able to re-write over the disc, I think I'll pick option one.

Or Excel. It asks, "Which of these documents, that you didn't save last time, do you want to save?" Hmm let me think. I guess I'd look at a few of them, and determine which one actually had my latest work. Or maybe I want to use an older version of my document. That might be helpful! Microsoft, tell me what to do!

When clicking on one of these links, you usually get directed to a help file. Interestingly, the first step in that help file is usually, "Use whatever method fits your needs". *rolls eyes*

Friday, September 13, 2013

An interesting workaround for non CLS-compliant variables

... I didn't say it was the BEST workaround...

But I ran into a situation recently in one of my company's VB.net projects where I had to pass a worksheet (Excel.Interop) into a new form (constructor). Apparently when you have a non CLS compliant object type passed into a constructor, you get the warning, "type of parameter is not CLS-complaint".

If you find VS warnings as annoying as I do, you want to get rid of that. You can do so by (caution, its overly simplistic): converting the worksheet to the generic Object class before passing it in. Then just re-convert it back to worksheet in the constructor.

I.E.
Dim arSheetHiding As Object = CType(arSheet, Object)
yourForm = New YourForm(arSheetHiding)
...
Public Sub New(ByVal sheet As Object)
        InitializeComponent()
        Dim wkst As Excel.Worksheet = CType(sheet, Excel.Worksheet)
        _WorkSheet = wkst
        ...
End Sub

This does create more code but you get that "0 warnings feeling" that you're taking good care of your project.