Pages by tag

5 pages are tagged with Coding CSharp VB

To check more tags, click here  click to open

Calculating floating holidates


When rendering a calendar's dayboxes or creating a company's HR days-off list, figuring out New Years Day, Christmas and Valentines Day are easy, but what about those floating holidays that depend on the instance of the Day in the Month?

This set of utilities gives a dev a lot of options plus offers protection against accidental weird arguments.

What's more, now all floating Holidays a company cares about are simply defined in a config file with month, instance number and/or flag for relative instance position from start or end of the month. (Non-floating holidays are likewise easily defined with a flag for specific Day number.)

Example test harness: start a Winform project, copy the class code to a class file, drop two textboxes on the form (txtDate and txtInstance), add a button to the form, double click on the button and paste this code in the stub:

Simple address formating


If you've ever bought address records or hired a company to do DE following a major direct mailing or just had to work a site that gets a lot of address posted you see how how little effort is usually spent on getting address strings into a standard format to help cut down on duplicates and make query results more useful. That's really too bad because it's not that hard to get the lion's share of the raw text into a consistent format.

The simple class below is a good one for your utility library. It takes a raw address string, removes extra spaces then converts direction and street labels to standard abbreviations.

Free-form sorting lists of Objects


Both Arrays and Arraylists implement IList which means that they both expose a Sort method. Thing is that for anything custom you have to define exactly how the elements should compare themselves to other elements for a Sort to happen.

Many resources tell you that sorting elements in these "collections" should be done by implementing IComparable and creating a CompareTo method on the item class itself (if it is not a primative that already has one built-in). For example if you have a Person object then they say that you should create a custom hard-coded CompareTo method in the Person class code that takes the LastName public variable and uses that for the comparisons that add up to a sorted list.

The problem comes when you have an object or struct that could be sorted in a few different ways depending on current needs, even a simple Person object might sometimes be more useful sorted on say an Address property instead of just the last name.

VB Must Be Killed!


You still here? Cool. You get a special door prize. Here's an autorun exe you can stick on any cd or dvd-rom to kick off an html page.

Use this for your program install cds or to automatically show Aunt Martha a cd full of family pictures.

Like I said, making great looking and highly interactive startup screens with Delphi is a breeze (Can you say DemoShield-killer?) but making great looking web pages only takes a working knowledge of Notepad. The problem is that cd/dvd AutoRuns only work against actual executables. So this is a real executable; It does nothing more than shell the user's default web browser to open an HTML page located in the same folder.

Name the page you want to start "Default.htm" and save it to the root directory of the cd, drop the autorun.exe and autorun.inf text file in the root directory of the cd.

Easy gradient forms


Companies know that an app can have all the best functionality but if it doesn't look spiffy it won't sell. Offer users an upgrade that has no difference but pop-up flat buttons and they'll pay the price.

Time was when you wanted to get a gradient background on a form you had to do a lot of API work, and in VB the redraws were never quite quick enough. Plus the complexity of dealing with areas that needed to be repainted vs areas that didn't and setting a forms' controls to match the form gradient of their location led most of us to go for custom controls.

Times have changed.

Create a new form, add a label (name it "lblTest" and give it a Text value), add a button (name it "butClickMe" and give it a Text value). Doubleclick on the form to bring up code view. Now, navigate to the Paint event and drop in this code:

<< 1 >> 
who is smith     contact smith     rss feed
Since 1997 a place for my stuff, and it if helps you too then all the better