Tuesday, February 15, 2005 2:48:04 PM UTC :: Filed Under ASP.NET | VB.NET

Admit it, you do it to.  You can’t remember the .NET way to do something, so you give-in and put Imports Microsoft.VisualBasic at the top of your .vb file.  It’s time to stop the madness! Where there is help, there is hope.

As of recently, a co-worker explained to me the virtues of not using the old-school VB namespace in favor of learning the newer VB.NET way of doing things.  One of the benefits is that VB.NET code is typically optimized to run faster… and we all love speed, don’t we?    There were two places in particular that I kept resorting to the old VB way: date manipulation and formatting.

For example, here is the old VB way to add 7 days to the current date:

DateAdd(DateInterval.Day, 7, Date.Now)

And here is the VB.NET way:

Date.Now.AddDays(7)

That’s not so bad, is it? Now let’s look at formatting.  Sure, there are quite a few ways to do the same thing, but here’s an example.   If you want to format a date type variable in VB:

Format(Date.Now.ToString, "MM/dd/yyyy")

… or …

FormatDateTime(Date.Now, DateFormat.ShortDate)

And in VB.NET:

Date.Now.ToString("MM/dd/yyyy")

Actually, the VB.NET way seems easier! I wish I would’ve explored the VB.NET method sooner.

Here's some more handy conversions:

To subtract to dates:

Dim dblDateDiff As Double = datEndDate.Subtract(datStartDate).Days

So far, I’ve only come across one VB function (but I’m sure there are more) that I haven’t been able to find a VB.NET replacement for: vbTab.  I found the replacement for vbCrLf is Environment.NewLine (one of the new VB.NET classes that is actually less convenient than its VB counterpart), but I have yet to find a way to put a simple tab space into a string.  Not a huge problem, but odd in my opinion since that means I can’t completely lay the Visual Basic namespace to rest!

To help yourself cure your addiction to Visual Basic (the old-school kind), set the filter in the Microsoft Visual Studio.NET 2003 Documentation library to ‘.NET Framework’ instead of ‘Visual Basic’.  I was under the impression that the ‘Visual Basic’ filter meant VB.NET, but it does not.

Friday, January 28, 2005 9:48:18 PM UTC :: Filed Under Geek Tips

Microsoft Word has got to be one of the most frustrating applications on the planet.  It typically takes me hours to figure-out how to do things that I would think should be simple, such as having a document that contains portrait and landscape oriented pages which all contain a footer with consecutive page numbering.

To change one or more pages in a document from portrait to landscape orientation, select File > Page Setup… and then click the Margins tab.  If you select the This Page Forward option under the Applies To area, all pages after the current page will be rotated when you select the landscape orientation. 

That’s all well-and-good, but if you have your pages automatically numbered in the footer, switching one page to landscape orientation also creates a new Section in the document and starts page numbering over from 1. Argh!

So, what to do?  Well, where there’s help, there’s hope.  After creating a set of landscape oriented pages, select View > Headers and Footers.   Select the footer of the first landscape page and make sure the Link to Previous button is not selected. 

Figure 1: The Header and Footer Tool Bar

Then click the Format Page Number icon (the one with the # symbol and the hand as shown in Figure 1) and select Page Numbering > Continue From Previous Section radio button as shown in Figure 2. That’s it!

Figure 2: The Page Number Format Window

Wednesday, January 19, 2005 6:45:03 PM UTC :: Filed Under ASP.NET | VB.NET

Microsoft Certified Application DeveloperYippee!  After studying for the 70-310 exam (XML Web Services and Server Components using VB.NET) for months, I took it this morning for the first time and passed!  

This is the third Microsoft exam I've taken, so that bumps me up to the MCAD.NET status.   To me, the exam was really tough... the toughest so far.  I've taken the 70-229 exam (SQL Server) and 70-305 exam (VB.NET Web Apps) previously and although they were challenging, I had more experience to back my studying for those two tests.   As of yet, I've only used web services minimally and I've never had to create or use a service component.  Despite my lack of current experience with XML web services and server controls, I opted to take the 70-310 because I feel that applications such as Microsoft BizTalk Server will be more and more important in the future as the need to exchange data between desperate systems becomes crucial to being competitive in the business world.

To get my MSCD.NET certification, my next exam will be the 70-300 exam (Analyzing Requirements and Defining Solution Architectures), followed by the 70-306 (Windows-Based Apps w/ VB.NET).

Friday, January 14, 2005 1:10:16 AM UTC :: Filed Under Fitness

Live Strong Wristband ImageAs a bicyclist, I probably one of the first to be interested in Lance Armstrong’s LIVESTRONG campaign.  Ever since he won his 6th consecutive Tour de France, it seems like everyone and anyone can be seen wearing his LIVESTRONG armbands. Most wearing the band could probably care less about biking or the Tour de France, but are likely supporting the fight against cancer for which this band symbolizes.

Will I’m all for people supporting cancer research (I have two of the bands as well), I have to wonder how many people who buy these bands actually “live strong” and how many just buy the bands in the hopes that their $1 contribution will contribute to what is someday the cure for cancer?  To me, the point of the band, beyond the $1 contribution, is to tell people, “Hey!  I’m choosing to lead a better life for myself and not just become another over-weight, lazy human!  I am going to 'live strong' by taking care of my mind and body so that it I may lead a better life.”   Obviously, Lance truly is “living strong”… his body is in better shape than probably 99.999999% of the rest of the world and that’s probably the reason why his body was able to fight off his cancer.

Improving your own health through proper diet and exercise as well as encouraging others to do the same will do more for fighting cancer than monetary contributions and yellow bands will do… yet how many people who buy these bands take a serious look at their own lifestyle and make the change to “live strong”?  As of recently, the government (well, the U.S. Food & Drug Administration) recently changed its recommendations for good health to basically stating, “eat less, exercise more.” This includes 30-minutes to an hour of exercise every day in addition to recommending that we eat a ton of fruits and vegetables, grains, etc. Typically, when the government makes a recommendation, it’s not setting a very high standard but more of a “minimum requirement”… do you get as much exercise as they recommend? Heck, I like to think I’m active and even I don’t!

The American Cancer Society, American Diabetes Association, and the American Heart Association have teamed-up to address this problem of people simply not taking care of themselves by creating a web site called Everyday Choices.  You may have already seen their television add called “Protect Yourself” which depicts a woman who locks herself into her apartment to protect herself form intruders, only to plop-down on the couch, light-up a cigarette and eat some junk food.  (You can see this commercial and get many other useful health tips on the Everyday Choices web site.)   Unfortunately, I knew far too many people who smoke, eat a steady diet of junk food, and are nearly allergic to exercise, yet these same people often sport a yellow band on their wrist.  Isn’t something wrong with this picture?

Anyway, I know it’s hard to truly “live strong”, at least by my standards… but I’m going to keep trying.

Wednesday, January 05, 2005 3:35:19 AM UTC :: Filed Under Web Design
How CSS can make those ugly HTML submit buttons look pretty.
Navigation
On this page....
Search
Archives
<February 2005>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272812345
6789101112
Categories
Contact me
Send mail to the author(s) Contact Todd M. Taylor