Home » Posts tagged "vb.net"

Magic Strings and Magic Numbers

This past week a very old (last time I did work for him was in 2007) client of mine contacted me because their program suddenly started exhibiting a problem.  It seems that if a user enters a date anytime in 2015, the program displays an error message indicating that they need to enter a date greater than today and less than two years from today.

When I went to replicate the error in my debugger, I discovered this bit of code:

Continue reading “Magic Strings and Magic Numbers”

VB.NET Nullable Types

tp_vol4_001

SQL has long had the ability to specify that a value is NULL even if it is a primitive type, but the only way you could have a NULL value in VB.NET is if you were dealing with an object.

That is, until .NET 2.0

Even though .NET 2.0 has been out for a while, I would bet that few VB.NET programmers know about this new feature because it is one of those things most of us have grown to assume is not possible.

Values must have content–objects don’t.  That’s just the way it is.

Continue reading “VB.NET Nullable Types”

Test Sending Email without a Server in ASP.NET

back-041 By now, most people are familiar with the fact that ASP.NET will send mail from the codebehind by simply adding a few lines to your web.config file and adding another few lines of code in the codebehind file.

But it wasn’t until recently that I found that you don’t need to have access to an SMTP server to test your code.

Continue reading “Test Sending Email without a Server in ASP.NET”

VB.NET Processing Before WinForm Display

arct-075

I woke up this morning to an interesting question.

“Using VB.net 2008, I want my project to be a Windows Forms Application, but upon startup, I want to check a few files to see if they exist and if they don’t I do not want the startup form to load. I just want the program to quit. If you have to start this type of application with a form, how do you keep the form from displaying?”

Continue reading “VB.NET Processing Before WinForm Display”

Manually Adding Event Handlers in VB.NET

office-019

Typically when we write our code, the event handlers get wired up for us using the handles clause.  So we never have to worry about wiring up our event handlers manually.

But what about the case where we want to dynamically add a control to our Windows Form or our ASP.NET page?  For example, add a button.  How would you respond to the button click event?

Continue reading “Manually Adding Event Handlers in VB.NET”