Home

VB.NET: List Classes That Inherit Interface

Posted by SteveHardie | On: May 19 2011 | Comments (0)
I want to be able to create a list of all classes that inherit a specified interface within a given namespace. Here is a quick bit of code that will give you a list of System.Type wich will contain all classes that inherit the specified interface.

tSQL Return Identity When Adding New Record

Posted by SteveHardie | On: Mar 21 2011 | Comments (0)
@@Identity (Transact-SQL) Is a system function that returns the last-inserted identity value. To use this in a tSQL statement, you need to declare an output variable and set the value after inserting a new row into a table. SET @RecordID=@@IDENTITY Using...

Javascript: How to use ASP.NET Forms Validation from Javascript

Posted by SteveHardie | On: Jun 24 2010 | Comments (1)
ASP.NET has a Page.Validate() method that is used to programatically validate an ASP.NET Form, however, Page.Validate() is a server side function and requires a postback. Its job is to run server side validation. So to run client-side validation, without causing...

VB.NET How many weekdays between two dates

Posted by SteveHardie | On: May 02 2010 | Comments (2)
Here is a quick way to find out how many times a particular day of the week occurs between two dates. For example, how many sundays between two dates. Protected Function findWeekDays(ByVal startDate As Date, ByVal endDate As Date, ByVal DayOfWeek As Microsoft.VisualBasic.FirstDayOfWeek)...

Read Text From/Write Text To a File

Posted by SteveHardie | On: Nov 13 2009 | Comments (0)
This is a quick and easy way to read a files content into a string, or write a string to a file. Read File Contents: Dim strContent As String Using fs As New IO.StreamReader(fileName) strContent = fs.ReadToEnd End Using Write content to file: Dim strContent...

VB.NET Format File Size

Posted by SteveHardie | On: Oct 07 2009 | Comments (1)
Format a large integer (long) that represents a file size in bytes to a more readable string representation that includes Kb, Mb and Gb. Public Shared Function FormatFileSize(ByVal FileSizeBytes As Long) As String Dim sizeTypes() As String = {"b",...

VB.NET Finding a File Size

Posted by SteveHardie | On: Oct 07 2009 | Comments (0)
There may be some situations where you would like to retrieve the size of a given file. Below is a quick piece of code that will do exactly that. It will return the size of the file in bytes. Imports System.IO Private Function GetFileSize(ByVal MyFilePath As String)...

Regular Expression Validation for Email Address

Posted by SteveHardie | On: Sep 29 2009 | Comments (0)
In almost all cases, it is a good practice to validate the users input because of many reasons (i.e. security, reliability, as proof of the given template, etc.). There is a quick and simple way to check if a text box entry contains a valid email address. A valid...