smithvoice.com
Pages by tag

38 pages are tagged with VB


To check more tags, click here  click to open


Calculating floating holidates


Summary:

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


Summary:

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


Summary:

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.Next or bust?


Summary:

Why does this silliness continue?

Aren't we the smart ones, we technical people?

Jeff Richter is one of the most respected VC++ people in the world, he says the rote line 'All languages are equal' but he also says that 'C# is the better tool'. He said that flat out to me over dinner at a WinDev. Human. He has his followers who hear only the part they want to hear to make themselves feel special. Human.

Founder of APress and Desaware, Dan Appleman is an older C++ veteran, I believe that he has a bit more real-world experience with a lot of different tools than most of us have (including Mr. Richter). And after some analysis he says about the bits and bytes "There is no difference at all"



Wide interval timers


Summary:

We have a WinForms program doing DataWarehouse report functions and need to include the option of firing off events at pretty long intervals (hours, and even days between them) and want to be able to tell the user that the app is still running with a bit of detail. I was thinking of showing a countdown in a label but the DateAdd functions are confusing me. Do you have any pointers?

What you're looking for isn't all that difficult, depending on the accuracy you require. I do have to say that you might want to look into serverside timing and having the desktops check the status of reports rather than kicking off the processing from a user GUI; Having a server manage the timing is probably going to be a little safer than asking users to keep their machines on for days at a stretch ... but that's up to you.

Even if you do rethink the architecture of this project, the trick you're looking for ...



Windows Media Attributes


Summary:

I need to read the attributes of windows media files, audio and video. I can do it by automating the Media Encoder but we really don't want to force that 10MB full GUI onto the user machines, is there a way to do this directly?

"Directly"? Yeah, you can get the ASF/WM format spec and parse, but Perl or PHP would be the better tool for that.
We made a demo app for you that shows the SDK attribute code ported to VB.Net, it should get you started ...



VB Must Be Killed!


Summary:

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.



Your own image control and App part 1


Summary:

Let's imagine we're in an end user planning session, at the point where all of the company gossip is over and the brown dribbles have dried down the sides of the cold coffee cups. The five real minutes of work in that hour and a half meeting boiled down to the following functional spec:

  1. We need to have a program that lets us load various image files including JPEGs, BMPs, PNGs, GIFs and "Faxes" ("faxes" are always thrown in when we're not listening closely)
  2. We need to be able to rotate the images.
  3. We need to be able to zoom in and out of the images.
  4. We need to be able to select parts of an image and save just the selection as a new image ("crop").
  5. We need to save the rotated/cropped image out to a new image file with various file type options.
  6. We need it done two weeks ago or the company will go under and we'll have to move to India to beg for coins from the only people left in the world doing real tech work.


Your own image control and App part 2


Summary:

Setting up the workspace

Load Visual Studio and on the Start page, click on the "New Project" button. In the top left "Project Types" tree, select "Visual Basic Projects" and in the right "Templates" pane choose the "Windows Control Library" template. Down at the bottom of the screen, name the project "svImageEdit" and press OK.

This next part may seem a little odd, just trust me. When the project is ready, right click on the Usercontrol.vb node of the Solution Explorer tree and click on "Delete" to kill the default file. Now right click on the project node and on the popup click on "Properties" and in the popup set the "Default Namespace" to "Smithvoice" (You can use the name of your company or organization, just remember to use your value where I type "Smithvoice" later in the code). Press OK to close the project properties form. Right click again on the project node and click on the popup's "Add User Control" option and use the wizard to create a new UC named "svImageEditor".



Your own image control and App part 5


Summary:

If you tested the image loading with a "fax image" *.tif file (or *.tiff" file) you probably got it to display... sort of. Faxes received by computers are traditionally held in TIF files, but TIFs aren't exactly Image files in the manner of *.bmp, *.gif and *.jpg/*.jpeg.

To get at the collection of a TIF's images back in the VBCom days the path of least grief was to buy into a 3rd party tool such as LeadTools, but .Net makes working with TIFs a lot easier. Now, with our own GDI+ and System.Drawing code we can not only read the images but also add, delete and edit a file's internal image collection.



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