Getting .NET Button ListBar control to work

Dave (DarkAngel) has responded to my call for help regarding the .NET Button ListBar Control and has kindly allowed me to post the solution here. Dave is the man really - he went through the trouble of grabbing the control, loading up VS.NET and working through it step by step with me in his email. All that for a stranger. I love you Dave!

The problem I had was trying to import the .NET Button ListBar Control into my VS.NET Toolbox. The instructions said to import the ButtonListBar.vb file into the project and it should work, but it doesn’t in Visual Studio.NET 2003. I think that is the reason it didn’t work (that it is VS.NET 2003 instead of just VS.NET).

Opening the ButtonListBar.vb file in the Designer threw out an error (see the call for help entry). Dave fixed that with this solution (also via email):

… move the region event argument classes to the end of the ButtonListBar.

He went on to help me compile the source files into a DLL, which I’m familiar with using for importing controls. Below are his instructions (slightly paraphrased). The credit goes solely to Dave (DarkAngel) - I’m merely reproducing it for the benefit of anyone who next comes across this problem.

  1. Open up Visual Studio .NET (Visual Studio .NET 2003 to be exact)
  2. Create a new project by clicking File -> New Project (I’m using Visual Basic, so I chose Visual Basic Project).
  3. Choose “Windows Control Library”.
  4. What we’ve done so far is just create a control library project which is ideal for putting new controls in. This will build to a DLL.
  5. Remove UserControl1.vb (the default file VS.NET creates) from the Solution Explorer (it’s unnecessary).
  6. Right click the project in the solution explorer and select Add -> Add existing item
  7. Add the ButtonListBar.vb file in the control source files downloaded.
  8. Build the project (choose to build for “Release”).
  9. The compiled DLL will then be in the bin/ directory of the project folder. You now have the ButtonListBar control in DLL form. All the remains is to add this control into the Toolbar of the project in which you want to use it.

Using the control:

  1. In the project you want to add the toolbar to, right-click your Toolbox and select “Add/Remove items”.
  2. Click “Browse” under the .net framework components tab.
  3. Browse to the location of the DLL we just created and double click it.
  4. Click OK to dismiss the Add/Remove items dialog.
  5. The ButtonListBar control should now be the bottom entry on your list. (You can right-click and sort alphabetically if you like).

Help needed with .NET and Java

Update: Dave has an excellent solution to the ButtonListBar .NET control problem.

Firstly, the .NET question: does anybody know how to get this Button ListBar Control to work?

I was trying to get the.NET Button ListBar control into my VB project’s toolbox - I followed these instructions:

To use the control, add either the ButtonListBar.vb or ButtonListBar.cs file to your project. You should find the control automatically appears in the Toolbox; if not you’ll need to force the toolbox to display the
control: typically I find that double clicking on the control source file to open its designer causes this to occur.”

Unfortunately, it doesn’t appear automatically when I added ButtonListBar.vb (via “Add existing item”). So I double-clicked the source file… But it threw out this error

The class ButtonListBar can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file…

Which I don’t understand of course. Neither did it cause the ListBar control to appear in the Toolbox. I have emailed the author about this, but if anyone knows what I’m doing wrong, please let me know ASAP.

This of course leads to the question: What is the correct way to add a user control which comes in source form?

Now, for the Java question: is there an existing library/package that would allow me to calculate the median and, say, the 95th percentile of a population quickly? I searched to no avail, of course, before I ask this.

I can do this myself the hard way, but I’m really pressed for time. I’d like to reuse an existing solution if there is any.

Thanks for any leads!

VB.NET boolean operators and short-circuit evaluation

… short-circuit evaluation is how the logical human brain works when confronted with chained boolean conditionals in real life

Having to pick up VB.NET for a Human Computer Interaction course this semester, I’ve been spending some time getting acquainted with the language through a couple of books. Every now and then I get somewhat bemused by how “different” VB syntax is - not that it’s a bad thing, pray. Syntax, as almost everyone agrees, is secondary to semantics.

Anyway, here’s a particularly bemusing bit of trivia you can use to taunt/jibe/provoke your VB.NET/VB programmer friends.

Did you know that VB.NET’s default boolean operators And and Or do not take advantage of short-circuit evaluation? Take for example this snippet of conditional code below:

Dim x as Integer 1
If (x < 5) Or (x > 10) Then

Now, you’d expect your run-of-the-mill compiler/interpreter to optimize by short-circuiting the 2nd boolean expression, since the 1st expression is already true (and so whether the 2nd boolean expression is true or false doesn’t really matter). For some reason, probably one steeped in history, VB.NET, or rather the JIT compiler, doesn’t short-circuit. It happily goes ahead and evaluates the 2nd boolean expression.

This is logically ludicrous - short-circuit evaluation is how the logical human brain works when confronted with chained boolean conditionals in real life. If the university says I can only get a First Class Honours degree if my CAP is greater than 4.5 AND get a minimum of A- for my thesis, I won’t really fret about not getting an A- for my thesis (and subsequently missing out on a yummy First Class Honours) when my CAP can never hit 4.5.

Now to be fair, there is an alternative OrElse operator which does perform short-circuit evaluation. It is not fair though to expect such an unorthodox operator to be something your common on-the-street (read: non-VB) programmer will expect to exist (unless he reads a VB.NET book and bothers to flip to the introductory chapters).

Come to think of it, it could be an intended design issue. Evaluating the 2nd boolean expression could be always warranted when it produces a side effect. That must be the reason why Microsoft introduced the OrElse and AndAlso operators and leaving the standard And and Or operators as non-short-circuiting to prevent confusing converting VB programmers.

So this then is actually an issue with VB. Hence, we can conclude that they deserve to be taunted/jibed/provoked. Spare the VB.NET programmers. For now.